Docker 自定義網橋後,無法正常啟動問題

衣舞晨風發表於2017-03-06

週末用docker設定固定ip之後,再次輸入啟動命令之後,都報錯誤,具體如下:

root@ubuntu:~# docker version
Client:
 Version:      1.12.6
 API version:  1.24
 Go version:   go1.6.2
 Git commit:   78d1802
 Built:        Tue Jan 31 23:35:14 2017
 OS/Arch:      linux/amd64
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
root@ubuntu:~# service docker start
Job for docker.service failed because the control 
process exited with error code. See "systemctl status 
docker.service" and "journalctl -xe" for details.
root@ubuntu:~# systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: e
   Active: failed (Result: exit-code) since Mon 2017-03-06 16:59:47 CST; 29s ago
     Docs: https://docs.docker.com
  Process: 9757 ExecStart=/usr/bin/dockerd -H fd:// $DOCKER_OPTS (code=exited, s
 Main PID: 9757 (code=exited, status=1/FAILURE)

Mar 06 16:59:47 ubuntu dockerd[9757]: time="2017-03-06T16:59:47.326263971+08:00"
Mar 06 16:59:47 ubuntu dockerd[9757]: time="2017-03-06T16:59:47.326847904+08:00"
Mar 06 16:59:47 ubuntu dockerd[9757]: time="2017-03-06T16:59:47.327433829+08:00"
Mar 06 16:59:47 ubuntu dockerd[9757]: ........time="2017-03-06T16:59:47.34000826
Mar 06 16:59:47 ubuntu dockerd[9757]: time="2017-03-06T16:59:47.378659103+08:00"
Mar 06 16:59:47 ubuntu dockerd[9757]: time="2017-03-06T16:59:47.401407972+08:00"
Mar 06 16:59:47 ubuntu systemd[1]: docker.service: Main process exited, code=exi
Mar 06 16:59:47 ubuntu systemd[1]: Failed to start Docker Application Container 
Mar 06 16:59:47 ubuntu systemd[1]: docker.service: Unit entered failed state.
Mar 06 16:59:47 ubuntu systemd[1]: docker.service: Failed with result 'exit-code
root@ubuntu:~# journalctl -xe
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit docker.socket has finished starting up.
-- 
-- The start-up result is done.
Mar 06 17:07:38 ubuntu systemd[1]: Starting Docker Application Container Engine.
-- Subject: Unit docker.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit docker.service has begun starting up.
Mar 06 17:07:38 ubuntu dockerd[9944]: time="2017-03-06T17:07:38.217987846+08:00"
Mar 06 17:07:39 ubuntu kernel: audit: type=1400 audit(1488791259.311:58): apparm
Mar 06 17:07:39 ubuntu audit[9980]: AVC apparmor="STATUS" operation="profile_rep
Mar 06 17:07:39 ubuntu dockerd[9944]: time="2017-03-06T17:07:39.327277215+08:00"
Mar 06 17:07:39 ubuntu dockerd[9944]: time="2017-03-06T17:07:39.330977072+08:00"
Mar 06 17:07:39 ubuntu dockerd[9944]: time="2017-03-06T17:07:39.331639712+08:00"
Mar 06 17:07:39 ubuntu dockerd[9944]: time="2017-03-06T17:07:39.332261285+08:00"
Mar 06 17:07:39 ubuntu dockerd[9944]: ........time="2017-03-06T17:07:39.34310685
Mar 06 17:07:39 ubuntu dockerd[9944]: time="2017-03-06T17:07:39.365163611+08:00"
Mar 06 17:07:39 ubuntu dockerd[9944]: time="2017-03-06T17:07:39.388542420+08:00"
Mar 06 17:07:39 ubuntu systemd[1]: docker.service: Main process exited, code=exi
Mar 06 17:07:39 ubuntu systemd[1]: Failed to start Docker Application Container 
-- Subject: Unit docker.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit docker.service has failed.
-- 
-- The result is failed.
Mar 06 17:07:39 ubuntu systemd[1]: docker.service: Unit entered failed state.
Mar 06 17:07:39 ubuntu systemd[1]: docker.service: Failed with result 'exit-code

通過查詢系統日誌:

root@ubuntu:/var/log# cd
root@ubuntu:~# cd /var/log
root@ubuntu:/var/log# ls
alternatives.log  dpkg.log         lastlog              vmware-vmsvc.log
apt               faillog          lightdm              wtmp
auth.log          fontconfig.log   speech-dispatcher    Xorg.0.log
bootstrap.log     fsck             syslog               Xorg.0.log.old
btmp              gpu-manager.log  syslog.1             yum.log
cups              hp               unattended-upgrades
dist-upgrade      installer        upstart
dmesg             kern.log         vmware
root@ubuntu:/var/log# cat syslog
//或者通過
root@ubuntu:/var/log# vim syslog

可以看到具體錯誤資訊如下:

Mar  6 17:07:38 ubuntu dockerd[9944]: time="2017-03-06T17:07:38.217987846+08:00" level=info msg="libcontainerd: new containerd process, pid: 9960"
Mar  6 17:07:39 ubuntu kernel: [21284.569382] audit: type=1400 audit(1488791259.311:58): apparmor="STATUS" operation="profile_replace" profile="unconfined" name="docker-default" pid=9980 comm="apparmor_parser"
Mar  6 17:07:39 ubuntu dockerd[9944]: time="2017-03-06T17:07:39.327277215+08:00" level=info msg="[graphdriver] using prior storage driver \"aufs\""
Mar  6 17:07:39 ubuntu dockerd[9944]: time="2017-03-06T17:07:39.330977072+08:00" level=info msg="Graph migration to content-addressability took 0.00 seconds"
Mar  6 17:07:39 ubuntu dockerd[9944]: time="2017-03-06T17:07:39.331639712+08:00" level=warning msg="Your kernel does not support swap memory limit."
Mar  6 17:07:39 ubuntu dockerd[9944]: time="2017-03-06T17:07:39.332261285+08:00" level=info msg="Loading containers: start."
Mar  6 17:07:39 ubuntu dockerd[9944]: ........time="2017-03-06T17:07:39.343106854+08:00" level=info msg="Firewalld running: false"
//注意下面這段錯誤資訊
Mar  6 17:07:39 ubuntu dockerd[9944]: time="2017-03-06T17:07:39.365163611+08:00" level=warning msg="could not create bridge network for id d6f9d6b857030363444f5dc8fcc8b131831f13b440fa317e10f82bf07e6a8f5d bridge name docker_new0 while booting up from persistent state: bridge device with non default name docker_new0 must be created manually"
Mar  6 17:07:39 ubuntu dockerd[9945]: time="2017-03-06T17:07:39.388542420+08:00" level=fatal msg="Error starting daemon: Error initializing network controller: Error creating default \"bridge\" network: bridge device with non default name docker_new0 must be created manually"
Mar  6 17:07:39 ubuntu systemd[1]: docker.service: Main process exited, code=exited, status=1/FAILURE
Mar  6 17:07:39 ubuntu systemd[1]: Failed to start Docker Application Container Engine.
Mar  6 17:07:39 ubuntu systemd[1]: docker.service: Unit entered failed state.
Mar  6 17:07:39 ubuntu systemd[1]: docker.service: Failed with result 'exit-code'.
~                                                                               

方法一:新建自定義網橋docker_new0

brctl addbr docker_new0

方法二:修改/etc/default/docker檔案
這裡寫圖片描述
修改成
這裡寫圖片描述
這樣再次登入使用的就是預設網橋docker0了。

再次執行docker啟動命令正常:

sudo systemctl start docker

該問題報出的異常有如下這些:

//錯誤資訊一
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
//錯誤資訊二
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.

作者:jiankunking 出處:http://blog.csdn.net/jiankunking

相關文章