Docker网络已禁用:警告:IPv4转发已禁用。网络将无法正常工作 [英] Docker Networking Disabled: WARNING: IPv4 forwarding is disabled. Networking will not work

查看:685
本文介绍了Docker网络已禁用:警告:IPv4转发已禁用。网络将无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Containers in a host "suddenly" loses connection to outside-world containers. However, some hosts were refreshed and suddenly we had the following situation:


  1. 该主机可以与其他主机通信。

  2. 在主机中运行的容器无法与其他主机通信。

以下是示例:

[root@pprdespap322 deploy]# ping ci.docker.company.net
PING 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 ms
64 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 1001ms
rtt min/avg/max/mdev = 0.282/0.311/0.341/0.034 ms

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

Now, from the container itself, we cannot ping the same host:

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

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

The first time I saw this warning was in the initial versions of Docker... Having Docker 1.9.1 and 1.10.3, How to solve this problem?

推荐答案

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

I reviewed http://chrisgilmerproj.github.io/ubuntu/network/docker/2013/09/05/ipv4-forwarding-and-docker.html and it helped me solving the problem on the host.

我在 /etc/sysctl.conf 中添加了以下内容:

I added the following to /etc/sysctl.conf:

net.ipv4.ip_forward=1

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

I then restarted the network service and validated the setting:

[root@pprdespap322 deploy]#  systemctl restart network
[root@pprdespap322 deploy]# sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1
[root@pprdespap322 deploy]# docker run -ti quay.io/coreos/registry ping ci.docker.company.net
PING 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 ms
64 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 1001ms
rtt min/avg/max/mdev = 0.306/0.317/0.329/0.021 ms

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

All containers now can communicate with outside world containers!

这篇关于Docker网络已禁用:警告:IPv4转发已禁用。网络将无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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