7

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?

7

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.

| improve this answer | |
  • I am still seeing this problem with Docker 1.9. Would you mind detailing your steps for removing "docker.io" and installing "docker-engine"? Did you manually remove docker0? – Andrew Guenther Nov 17 '15 at 22:15
  • @AndrewGuenther, I do not recall purposefully removing docker0, but I did remove/recreate it a few times with brctl from bridge-utils. Not sure what state it was left in when I upgraded to Docker 1.9. I removed docker.io with apt-get remove then apt-get autoremove. – marcv81 Nov 18 '15 at 2:19
  • 1.9.1? I am seeing 1.9.0 as the most recent in the 15.10 apt repository. Are you sure that is what you have? And if so, how did you install it? – Andrew Guenther Nov 18 '15 at 4:10
  • Read again, I wrote 1.9 :) I am not in front of that machine anymore, but it would have whichever version was on the Docker repo at the time. – marcv81 Nov 18 '15 at 4:58
  • In @AndrewGuenther's defence, I read "Docker 1.9 I" as "Docker 1.9.1" as well. – Mike Crowe Dec 13 '15 at 13:40
2

To me it's NetworkManager that messes up. Docker service creates bridge as it should then exposes it on dbus. NetworkManager kicks in seeing new interface on dbus and try to configure it (since it's stupid enough to know that bridge docker0 is already configured fine). NetworkManager sometimes succeeds configuring (re-configuring) docker0 but sometimes it will fail. So sometimes you reboot box and docker0 will have IP assigned, other times it will not.

To stop NetworkManager messing up add

iface docker0 inet manual

to /etc/network/interfaces assuming NetworkManager.conf has

[ifupdown] managed=false

which is default on 15.10

(bug should probably be raised to stop NetworkManager from messing up docker specific interfaces)

| improve this answer | |
  • I was about to give you a -1. Here is why: The original question is "How to cleanly setup the network Docker in Ubuntu Gnome 15.10?", but I don't see how you try to answer that question. Please click edit below your answer and try to answer the question. – MadMike Dec 11 '15 at 16:56
  • i precisely answered and provided solution which is to add ifce docker0 inet manual to /etc/network/interfaces - have you tried doing this? this way person who asked the question should never need restarting docker service to sort out missing ip address of docker0 - please provide cleaner solution if you know it – greg one Dec 12 '15 at 11:40
  • @gregone: I'm the OP, thanks for your contribution. The problem is solved already. In my case I would never get an IP after rebooting, so it might be a different cause. On a different note you may want to consider using punctuation more liberally. – marcv81 Dec 12 '15 at 15:10
  • @greg Okay, I see that you do provide a answer. I just had problems making head an tail of it. Sorry, I failed to see it. – MadMike Dec 13 '15 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.