Docker网络已禁用:警告:IPv4转发已禁用网络将无法正常工作

【字号: 日期:2024-03-31浏览:18作者:雯心
(adsbygoogle = window.adsbygoogle || []).push({}); 如何解决Docker网络已禁用:警告:IPv4转发已禁用网络将无法正常工作?

我查看了http://chrisgilmerproj.github.io/ubuntu/network/docker/2013/09/05/ipv4-forwarding-and-docker.html,它帮助我解决了主机上的问题。

我在 添加了以下内容:

net.ipv4.ip_forward=1

然后,我重新启动了网络服务并验证了设置:

[root@pprdespap322 deploy]# systemctl restart network[root@pprdespap322 deploy]# sysctl net.ipv4.ip_forwardnet.ipv4.ip_forward = 1[root@pprdespap322 deploy]# docker run -ti quay.io/coreos/registry ping ci.docker.company.netPING pprdespap324.corp.company.net (10.137.55.22) 56(84) bytes of data.64 bytes from pprdespap324.corp.company.net (10.137.55.22): icmp_seq=1 ttl=63 time=0.329 ms64 bytes from pprdespap324.corp.company.net (10.137.55.22): icmp_seq=2 ttl=63 time=0.306 ms^C--- pprdespap324.corp.company.net ping statistics ---2 packets transmitted, 2 received, 0% packet loss, time 1001msrtt min/avg/max/mdev = 0.306/0.317/0.329/0.021 ms

现在,所有容器都可以与外界的容器通信!

解决方法

主机中的容器“突然”失去了与外部容器的连接。但是,有些主机刷新了,突然我们遇到了以下情况:

主机可以与其他主机通信。主机中运行的容器无法与其他主机通信。

这是一个例子:

[root@pprdespap322 deploy]# ping ci.docker.company.netPING pprdespap324.corp.company.net (10.137.55.22) 56(84) bytes of data.64 bytes from pprdespap324.corp.company.net (10.137.55.22): icmp_seq=1 ttl=64 time=0.282 ms64 bytes from pprdespap324.corp.company.net (10.137.55.22): icmp_seq=2 ttl=64 time=0.341 ms^C--- pprdespap324.corp.company.net ping statistics ---2 packets transmitted,2 received,0% packet loss,time 1001msrtt min/avg/max/mdev = 0.282/0.311/0.341/0.034 ms

现在,从容器本身,我们无法对同一主机执行ping操作:

[root@pprdespap322 deploy]# docker run -ti quay.io/coreos/registry ping ci.docker.company.netWARNING: IPv4 forwarding is disabled. Networking will not work.ping: unknown host ci.docker.company.net

我第一次看到此警告是在Docker的初始版本中…有了Docker 1.9.1和1.10.3,如何解决此问题?

相关文章: