1.docker启动失败
root@localhost:~# systemctl daemon-reload && systemctl restart docker.service Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details. root@localhost:~# systemctl status docker.service ● docker.service - Docker Application Container Engine Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled) Drop-In: /etc/systemd/system/docker.service.d └─override.conf Active: failed (Result: exit-code) since Fri 2020-09-04 09:31:26 CST; 4s ago Docs: https://docs.docker.com Process: 19628 ExecStart=/usr/bin/dockerd -H unix:// -H tcp://127.0.0.1:2375 (code=exited, status=1/FAILURE) Main PID: 19628 (code=exited, status=1/FAILURE) Sep 04 09:31:26 kuaiyue systemd[1]: docker.service: Service hold-off time over, scheduling restart. Sep 04 09:31:26 kuaiyue systemd[1]: docker.service: Scheduled restart job, restart counter is at 3. Sep 04 09:31:26 kuaiyue systemd[1]: Stopped Docker Application Container Engine. Sep 04 09:31:26 kuaiyue systemd[1]: docker.service: Start request repeated too quickly. Sep 04 09:31:26 kuaiyue systemd[1]: docker.service: Failed with result 'exit-code'. Sep 04 09:31:26 kuaiyue systemd[1]: Failed to start Docker Application Container Engine.各种网页查找“docker.service: Service hold-off time over, scheduling restart”,然后并没有找到解决办法!
有说/etc/docker/daemon.json 格式不对,有说/etc/docker/daemon.json 改为/etc/docker/daemon.conf,都没有任何作用。
------------------------------------------------------------分割线------------------------------------------------------------------------------------------
最后找到原因的办法是,启动docker以后,立即执行journalctl -xe或者systemctl status docker.service,找到docker出错的原因。
如果journalctl -xe/systemctl status docker.service执行慢了,只能看到下面这样的
-- -- The result is RESULT. Sep 04 09:31:26 systemd[1]: docker.service: Service hold-off time over, scheduling restart. Sep 04 09:31:26 systemd[1]: docker.service: Scheduled restart job, restart counter is at 3. -- Subject: Automatic restarting of a unit has been scheduled -- Defined-By: systemd -- Support: http://www.ubuntu.com/support -- -- Automatic restarting of the unit docker.service has been scheduled, as the result for -- the configured Restart= setting for the unit. Sep 04 09:31:26 systemd[1]: Stopped Docker Application Container Engine. -- Subject: Unit docker.service has finished shutting down -- Defined-By: systemd -- Support: http://www.ubuntu.com/support -- -- Unit docker.service has finished shutting down. Sep 04 09:31:26 systemd[1]: Closed Docker Socket for the API. -- Subject: Unit docker.socket has finished shutting down -- Defined-By: systemd -- Support: http://www.ubuntu.com/support -- -- Unit docker.socket has finished shutting down. Sep 04 09:31:26 systemd[1]: Stopping Docker Socket for the API. -- Subject: Unit docker.socket has begun shutting down -- Defined-By: systemd -- Support: http://www.ubuntu.com/support -- -- Unit docker.socket has begun shutting down. Sep 04 09:31:26 systemd[1]: Starting Docker Socket for the API. -- Subject: Unit docker.socket has begun start-up -- Defined-By: systemd -- Support: http://www.ubuntu.com/support -- -- Unit docker.socket has begun starting up. Sep 04 09:31:26 systemd[1]: Listening on Docker Socket for the API. -- Subject: Unit docker.socket has finished start-up -- Defined-By: systemd -- Support: http://www.ubuntu.com/support -- -- Unit docker.socket has finished starting up. -- -- The start-up result is RESULT. Sep 04 09:31:26 systemd[1]: docker.service: Start request repeated too quickly. Sep 04 09:31:26 systemd[1]: docker.service: Failed with result 'exit-code'. Sep 04 09:31:26 systemd[1]: Failed to start Docker Application Container Engine. -- Subject: Unit docker.service has failed -- Defined-By: systemd -- Support: http://www.ubuntu.com/support -- -- Unit docker.service has failed. -- -- The result is RESULT. Sep 04 09:31:26 systemd[1]: docker.socket: Failed with result 'service-start-limit-hit'.上面没有说明出错原因。
===================================分割线===================================================
下面这个才写出了出错原因。 systemctl status docker.service
root@localhost:~# systemctl status docker.service ● docker.service - Docker Application Container Engine Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled) Drop-In: /etc/systemd/system/docker.service.d └─override.conf Active: activating (start) since Fri 2020-09-04 09:37:33 CST; 565ms ago Docs: https://docs.docker.com Main PID: 22738 (dockerd) Tasks: 9 CGroup: /system.slice/docker.service └─22738 /usr/bin/dockerd -H unix:// -H tcp://127.0.0.1:2375 Sep 04 09:37:33 dockerd[22738]: time="2020-09-04T01:37:33.445359792Z" level=info msg="pickfirstBalancer: HandleSubConnStateChange: 0x44205ee0e0, CONNECTING" module=grpc Sep 04 09:37:33 dockerd[22738]: time="2020-09-04T01:37:33.446973762Z" level=info msg="pickfirstBalancer: HandleSubConnStateChange: 0x44205ee0e0, READY" module=grpc Sep 04 09:37:33 dockerd[22738]: time="2020-09-04T01:37:33.447462812Z" level=info msg="ccResolverWrapper: sending new addresses to cc: [{unix:///run/containerd/containerd.sock 0 <nil>}]" module=grpc Sep 04 09:37:33 dockerd[22738]: time="2020-09-04T01:37:33.447526483Z" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc Sep 04 09:37:33 dockerd[22738]: time="2020-09-04T01:37:33.447668423Z" level=info msg="pickfirstBalancer: HandleSubConnStateChange: 0x44205ee3f0, CONNECTING" module=grpc Sep 04 09:37:33 dockerd[22738]: time="2020-09-04T01:37:33.448877970Z" level=info msg="pickfirstBalancer: HandleSubConnStateChange: 0x44205ee3f0, READY" module=grpc Sep 04 09:37:33 dockerd[22738]: time="2020-09-04T01:37:33.453395805Z" level=info msg="[graphdriver] using prior storage driver: overlay2" Sep 04 09:37:33 dockerd[22738]: time="2020-09-04T01:37:33.468522766Z" level=info msg="Graph migration to content-addressability took 0.00 seconds" Sep 04 09:37:33 dockerd[22738]: time="2020-09-04T01:37:33.471128434Z" level=info msg="Loading containers: start." Sep 04 09:37:33 dockerd[22738]: time="2020-09-04T01:37:33.498476011Z" level=warning msg="Running modprobe xt_conntrack failed with message: `modprobe: ERROR: could not insert 'xt_conntrack': Exec format error\ninsmod /lib/modules或者
root@localhost:~# journalctl -xe -- Subject: Unit docker.socket has finished start-up -- Defined-By: systemd -- Support: http://www.ubuntu.com/support -- -- Unit docker.socket has finished starting up. -- Support: http://www.ubuntu.com/support -- -- Automatic restarting of the unit docker.service has been scheduled, as the result for -- the configured Restart= setting for the unit. Sep 03 17:02:09 localhost systemd[1]: Stopped Docker Application Container Engine. -- Subject: Unit docker.service has finished shutting down -- Defined-By: systemd -- Support: http://www.ubuntu.com/support -- -- Unit docker.service has finished shutting down. Sep 03 17:02:09 localhost systemd[1]: Closed Docker Socket for the API. -- Subject: Unit docker.socket has finished shutting down -- Defined-By: systemd -- Support: http://www.ubuntu.com/support -- -- Unit docker.socket has finished shutting down. Sep 03 17:02:09 localhost systemd[1]: Stopping Docker Socket for the API. -- Subject: Unit docker.socket has begun shutting down -- Defined-By: systemd -- Support: http://www.ubuntu.com/support -- -- Unit docker.socket has begun shutting down. Sep 03 17:02:09 localhost systemd[1]: Starting Docker Socket for the API. -- Subject: Unit docker.socket has begun start-up -- Defined-By: systemd -- Support: http://www.ubuntu.com/support -- -- Unit docker.socket has begun starting up. Sep 03 17:02:09 localhost systemd[1]: Listening on Docker Socket for the API. -- -- The start-up result is RESULT. Sep 03 17:02:09 localhost systemd[1]: Starting Docker Application Container Engine... -- Subject: Unit docker.service has begun start-up -- Defined-By: systemd -- Support: http://www.ubuntu.com/support -- -- Unit docker.service has begun starting up. Sep 03 17:02:10 localhost dockerd[13483]: time="2020-09-03T09:02:10.110222230Z" level=warning msg="[!] DON'T BIND ON ANY IP ADDRESS WITHOUT setting --tlsverify IF YOU DON'T KNOW WHAT YOU'RE DOING [!]" Sep 03 17:02:10 localhost dockerd[13483]: time="2020-09-03T09:02:10.116773985Z" level=info msg="systemd-resolved is running, so using resolvconf: /run/systemd/resolve/resolv.conf" Sep 03 17:02:10 localhost dockerd[13483]: time="2020-09-03T09:02:10.118918145Z" level=info msg="parsed scheme: \"unix\"" module=grpc Sep 03 17:02:10 localhost dockerd[13483]: time="2020-09-03T09:02:10.118994581Z" level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpc Sep 03 17:02:10 localhost dockerd[13483]: time="2020-09-03T09:02:10.119106894Z" level=info msg="parsed scheme: \"unix\"" module=grpc Sep 03 17:02:10 localhost dockerd[13483]: time="2020-09-03T09:02:10.119299004Z" level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpc Sep 03 17:02:10 localhost dockerd[13483]: time="2020-09-03T09:02:10.120061161Z" level=info msg="ccResolverWrapper: sending new addresses to cc: [{unix:///run/containerd/containerd.sock 0 <nil>}]" module=grpc Sep 03 17:02:10 localhost dockerd[13483]: time="2020-09-03T09:02:10.122263838Z" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc Sep 03 17:02:10 localhost dockerd[13483]: time="2020-09-03T09:02:10.123354778Z" level=info msg="pickfirstBalancer: HandleSubConnStateChange: 0x442015b950, CONNECTING" module=grpc Sep 03 17:02:10 localhost dockerd[13483]: time="2020-09-03T09:02:10.125152357Z" level=info msg="pickfirstBalancer: HandleSubConnStateChange: 0x442015b950, READY" module=grpc Sep 03 17:02:10 localhost dockerd[13483]: time="2020-09-03T09:02:10.126387488Z" level=info msg="ccResolverWrapper: sending new addresses to cc: [{unix:///run/containerd/containerd.sock 0 <nil>}]" module=grpc Sep 03 17:02:10 localhost dockerd[13483]: time="2020-09-03T09:02:10.126982855Z" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc Sep 03 17:02:10 localhost dockerd[13483]: time="2020-09-03T09:02:10.127383233Z" level=info msg="pickfirstBalancer: HandleSubConnStateChange: 0x442015bc40, CONNECTING" module=grpc Sep 03 17:02:10 localhost dockerd[13483]: time="2020-09-03T09:02:10.128749117Z" level=info msg="pickfirstBalancer: HandleSubConnStateChange: 0x442015bc40, READY" module=grpc Sep 03 17:02:10 localhost dockerd[13483]: time="2020-09-03T09:02:10.129671905Z" level=info msg="[graphdriver] using prior storage driver: overlay2" Sep 03 17:02:10 localhost dockerd[13483]: time="2020-09-03T09:02:10.140991314Z" level=info msg="Graph migration to content-addressability took 0.00 seconds" Sep 03 17:02:10 localhost dockerd[13483]: time="2020-09-03T09:02:10.144513158Z" level=info msg="Loading containers: start." Sep 03 17:02:10 localhost dockerd[13483]: time="2020-09-03T09:02:10.164800986Z" level=warning msg="Running modprobe xt_conntrack failed with message: `modprobe: ERROR: could not insert 'xt_conntrack': ExSep 03 17:02:10 localhost dockerd[13483]: time="2020-09-03T09:02:10.140991314Z" level=info msg="Graph migration to content-addressability took 0.00 seconds" Sep 03 17:02:10 localhost dockerd[13483]: time="2020-09-03T09:02:10.144513158Z" level=info msg="Loading containers: start." Sep 03 17:02:10 localhost dockerd[13483]: time="2020-09-03T09:02:10.164800986Z" level=warning msg="Running modprobe xt_conntrack failed with message: `modprobe: ERROR: could not insert 'xt_conntrack': Exec format error\ninsmod /lib/modul根据上面的信息可以看到是加载内核模块xt_conntrack出错了。
至于加载失败的原因,我这边是缺少xt_conntrack模块,导致加载失败。
在网上看到另一种原因,xt_conntrack有,但是也加载失败了,
原因是xt_conntrack模块被加入到黑名单里面了。
重新编译内核,自动加载xt_conntrack,或者手动加载xt_conntrack以后,再启动docker,就没有报错了。