Docker网络挂起,需要重启daemon

Docker网络挂起,需要重启daemon

一切都运行正常,然后突然出现这种情况。网络第一次工作正常,但随后停止,除非我重新启动 docker 服务。

eduardo@debian:~$ docker run -it --rm busybox
/ # ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: seq=0 ttl=54 time=32.611 ms
64 bytes from 8.8.8.8: seq=1 ttl=54 time=16.220 ms
^C
--- 8.8.8.8 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 16.220/24.415/32.611 ms
/ # eduardo@debian:~$ docker run -it --rm busybox
/ # ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
^C
--- 8.8.8.8 ping statistics ---
6 packets transmitted, 0 packets received, 100% packet loss
/ # exit
eduardo@debian:~$ sudo service docker restart
eduardo@debian:~$ docker run -it --rm busybox
/ # ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: seq=0 ttl=54 time=12.769 ms
64 bytes from 8.8.8.8: seq=1 ttl=54 time=13.807 ms
^C
--- 8.8.8.8 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 12.769/13.288/13.807 ms
/ # exit
eduardo@debian:~$ docker run -it --rm busybox
/ # ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
^C
--- 8.8.8.8 ping statistics ---
4 packets transmitted, 0 packets received, 100% packet loss
/ # eduardo@debian:~$ 

运行时不会发生问题--network=host option

Linux 版本:

Linux debian 4.9.0-4-amd64 #1 SMP Debian 4.9.65-3+deb9u1 (2017-12-23) x86_64 GNU/Linux

测试的 Docker 版本:

17.12.0-ce, build c97c6d6
18.03.1-ce, build 9ee9f40

我注意到,当它工作和不工作时,traceroute 的输出有所不同。工作时:

/ # traceroute 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 46 byte packets
 1  172.17.0.1 (172.17.0.1)  0.003 ms  0.004 ms  0.001 ms
 2  10.0.2.2 (10.0.2.2)  0.268 ms  0.212 ms  0.167 ms
 3  *  *  *
 4  *  *  *
 5^C

不工作:

/ # traceroute 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 46 byte packets
 1  f9ac28e9e4db (172.17.0.2)  3065.434 ms !H  3090.835 ms !H  3075.977 ms !H
/ # 

看来导致它不起作用的原因是主机中缺少docker0路由。当我重新启动docker服务时,最后一行被重新创建:

$ ip route
default via 10.0.2.2 dev enp0s3 
10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15 
169.254.0.0/16 dev enp0s3 scope link metric 1000 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown 

答案1

wcid 服务似乎确实是原因。我在配置中发现:

(/etc/wicd/manager-settings.conf):wired_interface = docker0

我将其更改为 eth0

在 Stackoverflow 上找到了这个解决方案。

https://stackoverflow.com/a/39448733/129960

相关内容