我的 docker 容器没有互联网 [英] My docker container has no internet

查看:37
本文介绍了我的 docker 容器没有互联网的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我让它工作正常,但现在它停止了.我尝试了以下命令但无济于事:

docker run -dns 8.8.8.8 base ping google.com

docker run base ping google.com

sysctl -w net.ipv4.ip_forward=1 - 在主机和容器上

我得到的只是未知主机 google.com.Docker 版本 0.7.0

有什么想法吗?

附言ufw 也被禁用

解决方案

已通过以下建议修复:

<块引用>

[...] 你能尝试重置一切吗?

pkill dockeriptables -t nat -Fifconfig docker0 关闭brctl delbr docker0码头工人 -d

<块引用>

它将强制 docker 重新创建网桥并重新初始化所有网络规则

https://github.com/dotcloud/docker/issues/866#issuecomment-19218300

界面似乎以某种方式挂起"了.

更新 docker 的更新版本:

上面的答案可能仍然可以为您完成工作,但是自从发布此答案以来已经很长时间了并且 docker 现在更加完善,因此请确保在使用 iptables<之前先尝试这些/code> 和所有.

sudo service docker restart 或(如果您在不使用 upstart 的 linux 发行版中)sudo systemctl restart docker

I had it working allright but now it stopped. I tried the following commands with no avail:

docker run -dns 8.8.8.8 base ping google.com

docker run base ping google.com

sysctl -w net.ipv4.ip_forward=1 - both on the host and on the container

All I get is unknown host google.com. Docker version 0.7.0

Any ideas?

P.S. ufw disabled as well

解决方案

Fixed by following this advice:

[...] can you try to reset everything?

pkill docker
iptables -t nat -F
ifconfig docker0 down
brctl delbr docker0
docker -d

It will force docker to recreate the bridge and reinit all the network rules

https://github.com/dotcloud/docker/issues/866#issuecomment-19218300

Seems the interface was 'hung' somehow.

Update for more recent versions of docker:

The above answer might still get the job done for you but it has been quite a long time since this answer was posted and docker is more polished now so make sure you try these first before going into mangling with iptables and all.

sudo service docker restart or (if you are in a linux distro that does not use upstart) sudo systemctl restart docker

这篇关于我的 docker 容器没有互联网的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆