job.answiz.com
  • 0
Votes
name
name Punditsdkoslkdosdkoskdo

How to cleanly setup the network Docker in Ubuntu Gnome 15.10

In Ubuntu Gnome 15.10 Docker almost works out of the box but there is a subtlety. The containers do not seem to be able to access the network until I restart the docker service.

After booting the host the docker0 interface does not have any IP address.

$ ifconfig docker0
docker0   Link encap:Ethernet  HWaddr ea:03:cc:9c:7a:cd
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:108 (108.0 B)

If I then start a container the docker0 interface only gets an ipv6 address and no network connection is possible from the container as far as I can tell. I cannot ping the host IP, LAN IPs, or Internet IPs. I'm using the ubuntu:trusty image and running bash as the container's main process.

$ ifconfig docker0 
docker0   Link encap:Ethernet  HWaddr 00:00:00:00:00:00
          inet6 addr: fe80::7801:6eff:fe86:6dd8/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:14 errors:0 dropped:0 overruns:0 frame:0
          TX packets:25 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:704 (704.0 B)  TX bytes:3917 (3.9 KB)

If I restart docker then docker0 gets an ipv4 address (in addition to the ipv6 address) and everything works as expected.

$ sudo service docker restart 
$ ifconfig docker0
docker0   Link encap:Ethernet  HWaddr 00:00:00:00:00:00
          inet addr:172.17.42.1  Bcast:0.0.0.0  Mask:255.255.0.0
          inet6 addr: fe80::7801:6eff:fe86:6dd8/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:14 errors:0 dropped:0 overruns:0 frame:0
          TX packets:25 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:704 (704.0 B)  TX bytes:3917 (3.9 KB)

Of course I can restart the docker service every time I restart my machine, or probably hack a startup script to do it for me (I have not tried). Does anyone know of a clean way to fix this?

TL;DR: I had installed Docker using "apt-get install docker.io". Installing the latest version following https://docs.docker.com/installation/ubuntulinux/ fixes the issue.

After investigating the problem it appears that the version of Docker in 15.10 cannot both create and initialize the docker0 interface correctly. On the first run (service docker start) it will create the interface but fail to initialize it, and on the subsequent run (service docker restart) it will initialize it. This can be reproduced consistently adding and deleting the interface manually with brctl. This bug has been fixed in the latest Docker.

  • 0
Reply Report


Related Questions

Trending Tags