Everything was working fine then suddenly I'm getting this behavior. Network works the first time but then stops unless I restart docker service.
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:~$
Problem does not happen when running with --network=host option
.
Linux version:
Linux debian 4.9.0-4-amd64 #1 SMP Debian 4.9.65-3+deb9u1 (2017-12-23) x86_64 GNU/Linux
Docker versions tested:
17.12.0-ce, build c97c6d6
18.03.1-ce, build 9ee9f40
I noticed different traceroute outputs when it is working and when it is not. Working:
/ # 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
Not Working:
/ # 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
/ #
It seems that what causes it to not work is the lack of the docker0 route in the host. When I restart docker service the last line is recreated:
$ 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
The wcid service seems to be the cause indeed. I found in the config :
(/etc/wicd/manager-settings.conf): wired_interface = docker0
I changed this to eth0
Found this solution at Stackoverflow.
https://stackoverflow.com/a/39448733/129960