我的 docker 容器没有互联网

编程入门 行业动态 更新时间:2024-10-27 10:33:21
本文介绍了我的 docker 容器没有互联网的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

docker run -dns 8.8.8.8 base ping google

docker run base ping google

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

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

有什么想法吗?

附言ufw 也被禁用

解决方案

已通过以下建议修复:

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

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

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

github/dotcloud/docker/issues/866#issuecomment-19218300

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

更新 docker 的更新版本:

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

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

docker run base ping google

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

All I get is unknown host google. 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

github/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 容器没有互联网

本文发布于:2023-11-27 17:00:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638846.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:互联网   容器   docker

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!