我在Ubuntu 14.04上运行Docker version 1.4.1, build 5bc2ff8
。当我用docker run
编码任何容器时,几分钟后我的docker0
桥“死亡”,并且该容器不再能够访问网络。在连接终止之前,运行ifconfig
会报告带有docker0
的inet addr
设备,例如:
docker0 Link encap:Ethernet HWaddr 56:84:7a:fe:97:99
inet addr:172.17.42.1 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: xxxx::xxxx:xxxx:xxxx:xxxx/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
[... etc.]
但是在连接终止后,
ifconfig
显示ipv4地址已消失:docker0 Link encap:Ethernet HWaddr 56:84:7a:fe:97:99
inet6 addr: xxxx::xxxx:xxxx:xxxx:xxxx/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8116 errors:0 dropped:0 overruns:0 frame:0
TX packets:15995 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2444859 (2.4 MB) TX bytes:17440729 (17.4 MB)
重新启动docker,例如使用
sudo service docker restart
可以备份设备-但是我所有的容器都死了,问题又重新出现了。我无法可靠地一次运行超过几分钟。对于大多数项目,还不够长,甚至无法完成docker build
。谢谢!
更新:我可以通过使用
docker0
启动一个容器,然后使用docker run -t -i ubuntu /bin/bash
退出,来可靠地触发这种丢弃ctrl-d
的行为。当我这样做时,这就是我在/var/log/syslog
中看到的内容myhost kernel: docker0: port 1(veth80ddeaf) entered disabled state
myhost kernel: device veth80ddeaf left promiscuous mode
myhost kernel: docker0: port 1(veth80ddeaf) entered disabled state
'
myhost dhclient: Internet Systems Consortium DHCP Client 4.2.4
myhost dhclient: Copyright 2004-2012 Internet Systems Consortium.
myhost dhclient: All rights reserved.
myhost dhclient: For info, please visit https://www.isc.org/software/dhcp/
myhost dhclient:
myhost dhclient: Listening on LPF/docker0/56:84:7a:fe:97:99
myhost dhclient: Sending on LPF/docker0/56:84:7a:fe:97:99
myhost dhclient: Sending on Socket/fallback
myhost kernel: IPv6: ADDRCONF(NETDEV_UP): docker0: link is not ready
更新#2:失败的频率似乎取决于容器运行的时间。例如:
docker run -i -t ubuntu sleep 0
--> `docker0` "survives" ~100% of the time
docker run -i -t ubuntu sleep 1
--> `docker0` survives ~80% of the time
docker run -i -t ubuntu sleep 5
--> `docker0` survives ~0% of the time
最佳答案
当docker0
具有IP地址时,如果您不启动任何容器,它会消失吗?如果它在启动容器之前无限期存在,那么我将首先查看Docker日志以及在启动容器时尾随系统日志。
ip地址是否以设定的时间间隔(例如,每N分钟)消失?如果是这样,我将从cron
中查找日志,以查看是否有一些定期任务负责。
您正在运行NetworkManager吗?禁用NetworkManager会使问题消失吗?我在使用NetworkManager的系统上运行Docker时没有问题,但是我在配置中设置了no-auto-default=*
,这可能会对这种情况产生影响。
更新
这是非常可疑的:
myhost dhclient: Internet Systems Consortium DHCP Client 4.2.4
myhost dhclient: Copyright 2004-2012 Internet Systems Consortium.
myhost dhclient: All rights reserved.
myhost dhclient: For info, please visit https://www.isc.org/software/dhcp/
myhost dhclient:
myhost dhclient: Listening on LPF/docker0/56:84:7a:fe:97:99
myhost dhclient: Sending on LPF/docker0/56:84:7a:fe:97:99
myhost dhclient: Sending on Socket/fallback
不应在
dhclient
上侦听任何docker0
进程,这绝对是导致您的IP地址消失的原因。如果您没有在此接口(interface)上显式运行dhcp客户端,则实际上表明NetworkManager实际上正在尝试管理该接口(interface)。您说过禁用了NetworkManager,但是您确认该过程已停止吗?在dhclient
上侦听的docker0
的父进程是什么?如果停止dhclient
进程,它会重新启动吗?问题解决了吗?关于networking - Docker的 `docker0`设备反复死亡(`inet addr`消失了),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28923743/