解决Docker Container in WSL2 发生DNS错误无法访问网络

问题

pull 了镜像,run 以后各种ping不通,也没法apt-get,
尝试了各种 --dns 和修改设置/etc/resolv.conf 的 nameserver 以及关闭bri,设置docker0 eth
都没有效果,报错无法解析地址和服务器。
不知道是不是因为wsl2 具有特殊性

后来想起来之前用的一组容器运行脚本是可以使用网络的。
经过对比,它使用了

--net=hadoop

的attribution,我在run新的docker container时
带上

--net=host

这样就可以正常解析域名了。

posted @ 2019-11-07 19:59  </Venus>  阅读(2009)  评论(1编辑  收藏  举报