[Work around/Fix] Docker loses network connectivity after first session terminates

Recently, I had trouble setting up docker, or to be more precise: running it. Every time I started the Docker daemon, and ran something like:

$ docker run busybox ping -c 3
PING ( 56 data bytes
64 bytes from seq=0 ttl=45 time=20.118 ms
64 bytes from seq=1 ttl=45 time=23.727 ms
64 bytes from seq=2 ttl=45 time=19.803 ms

--- ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 19.803/21.216/23.727 ms

Everything worked fine, but than the container was shut down, and I tried to run this container again it failed to connect/ping.

The first thing I noticed the docker0 network interface had lost its IP address. Restarting Docker fixed this problem, but for doing a simple ping, this is not a valid option. At first I though it might be the avahi-daemon causing trouble, because I found things like

Withdrawing address record for fe80::a80e:15ff:fe76:6a1e on veth8cdefb7.
Withdrawing address record for on docker0.

in my logs. But this was just an misinterpretation of the messages, I think.

It took my I while to come up with the idea to check the routes. What I observed, when ever an container stop and is terminated the docker0 interface was also shutdown and the route for this network and device were also deleted. Starting the container again did not add the route again.

As solution I have created a docker.network configuration - as I am using systemd - to configure the network and routes properly.





Enter your comment. Wiki syntax is allowed:
I​ I L Z᠎ M


Use the following URL for manually sending trackbacks: https://goatpron.de/lib/plugins/linkback/exe/trackback.php/blog:work_around_fix_docker_loses_network_connectivity_after_first_session_terminates
Last modified: le 2017/08/23 15:53