Docker 无法启动

Docker 无法启动

大家早上好,我是 docker 新手,所以我不太了解,但我需要安装它。我在 GoDaddy 有一个 VPS 托管,我按照以下步骤安装了 docker本指南当我尝试启动docker时出现错误:

docker.service 的作业失败,因为控制进程退出并显示错误代码。有关详细信息,请参阅“systemctl status docker.service”和“journalctl -xe”。

运行systemctl status docker.service我得到以下结果:

[root@ip-107-180-94-5 ~]# systemctl status docker.service -l
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/docker.service.d
           └─godaddy.conf
   Active: failed (Result: start-limit) since Wed 2020-01-29 06:49:01 MST; 4min 1s ago
     Docs: https://docs.docker.com
  Process: 3708 ExecStartPost=/opt/godaddy/docker/configure-snat (code=exited, status=2)
  Process: 3571 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=0/SUCCESS)
 Main PID: 3571 (code=exited, status=0/SUCCESS)

Jan 29 06:48:59 ip-107-180-94-5.ip.secureserver.net systemd[1]: Failed to start Docker Application Container Engine.
Jan 29 06:48:59 ip-107-180-94-5.ip.secureserver.net systemd[1]: Unit docker.service entered failed state.
Jan 29 06:48:59 ip-107-180-94-5.ip.secureserver.net systemd[1]: docker.service failed.
Jan 29 06:49:01 ip-107-180-94-5.ip.secureserver.net systemd[1]: docker.service holdoff time over, scheduling restart.
Jan 29 06:49:01 ip-107-180-94-5.ip.secureserver.net systemd[1]: Stopped Docker Application Container Engine.
Jan 29 06:49:01 ip-107-180-94-5.ip.secureserver.net systemd[1]: start request repeated too quickly for docker.service
Jan 29 06:49:01 ip-107-180-94-5.ip.secureserver.net systemd[1]: Failed to start Docker Application Container Engine.
Jan 29 06:49:01 ip-107-180-94-5.ip.secureserver.net systemd[1]: Unit docker.service entered failed state.
Jan 29 06:49:01 ip-107-180-94-5.ip.secureserver.net systemd[1]: docker.service failed.

运行journalctl -xe我得到以下结果:

[root@ip-107-180-94-5 ~]# journalctl -xe-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit user-0.slice has finished starting up.--
-- The start-up result is done.Jan 29 07:10:01 ip-107-180-94-5.ip.secureserver.net systemd[1]: Started Session 11104 of user root.-- Subject: Unit session-11104.scope has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel--
-- Unit session-11104.scope has finished starting up.
--
-- The start-up result is done.Jan 29 07:10:01 ip-107-180-94-5.ip.secureserver.net systemd[1]: Started Session 11105 of user root.
-- Subject: Unit session-11105.scope has finished start-up
-- Defined-By: systemd-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel---- Unit session-11105.scope has finished starting up.
--
-- The start-up result is done.
Jan 29 07:10:01 ip-107-180-94-5.ip.secureserver.net CROND[31560]: (root) CMD (/usr/local/cpanel/scripts/dcpumon-wr
Jan 29 07:10:01 ip-107-180-94-5.ip.secureserver.net CROND[31561]: (root) CMD (/usr/lib64/sa/sa1 1 1)

我关注了一些有同样错误的人的帖子,发现我所做的一切都有效。我通过运行获得了另一个结果dockerd --debug,它在下面一行停止,我需要中止该命令:

INFO[2020-01-29T07:14:39.129935890-07:00] API listen on /var/run/docker.sock

之后,如果我运行systemctl start docker它就会卡住而不返回,我需要再次中止该命令,然后我检查状态并systemctl status docker.service -l生成以下结果:

● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/docker.service.d
           └─godaddy.conf
   Active: activating (start-post) since Wed 2020-01-29 07:17:17 MST; 1min 39s ago
     Docs: https://docs.docker.com
 Main PID: 32176 (dockerd);         : 32313 (configure-snat)
    Tasks: 15
   Memory: 39.6M
   CGroup: /system.slice/docker.service
           ├─32176 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
           └─control
             ├─ 5261 sleep 0.1
             └─32313 /bin/bash /opt/godaddy/docker/configure-snat

Jan 29 07:18:56 ip-107-180-94-5.ip.secureserver.net configure-snat[32313]: Cannot connect to the Docker daemon atunix:///var/run/docker.sock. Is the docker daemon running?
Jan 29 07:18:56 ip-107-180-94-5.ip.secureserver.net configure-snat[32313]: waiting for docker bridge...
Jan 29 07:18:56 ip-107-180-94-5.ip.secureserver.net configure-snat[32313]: Cannot connect to the Docker daemon atunix:///var/run/docker.sock. Is the docker daemon running?
Jan 29 07:18:56 ip-107-180-94-5.ip.secureserver.net configure-snat[32313]: waiting for docker bridge...
Jan 29 07:18:56 ip-107-180-94-5.ip.secureserver.net configure-snat[32313]: Cannot connect to the Docker daemon atunix:///var/run/docker.sock. Is the docker daemon running?
Jan 29 07:18:56 ip-107-180-94-5.ip.secureserver.net configure-snat[32313]: waiting for docker bridge...
Jan 29 07:18:56 ip-107-180-94-5.ip.secureserver.net configure-snat[32313]: Cannot connect to the Docker daemon atunix:///var/run/docker.sock. Is the docker daemon running?
Jan 29 07:18:56 ip-107-180-94-5.ip.secureserver.net configure-snat[32313]: waiting for docker bridge...
Jan 29 07:18:56 ip-107-180-94-5.ip.secureserver.net configure-snat[32313]: Cannot connect to the Docker daemon atunix:///var/run/docker.sock. Is the docker daemon running?
Jan 29 07:18:57 ip-107-180-94-5.ip.secureserver.net configure-snat[32313]: waiting for docker bridge...

按照其他提示,我运行了dockerd命令并生成了结果:

WARN[2020-01-29T07:20:27.025438855-07:00] The "graph" config file option is deprecated. Please use "data-root" instead.
INFO[2020-01-29T07:20:27.025693705-07:00] Starting up
failed to start daemon: pid file found, ensure docker is not running or delete /var/run/docker.pid

于是我删除了.pid文件,结果变成:

WARN[2020-01-29T07:22:44.060324431-07:00] The "graph" config file option is deprecated. Please use "data-root" instead.
INFO[2020-01-29T07:22:44.061145504-07:00] Starting up
INFO[2020-01-29T07:22:44.064401028-07:00] parsed scheme: "unix"                         module=grpc
INFO[2020-01-29T07:22:44.064684277-07:00] scheme "unix" not registered, fallback to default scheme  module=grpc
INFO[2020-01-29T07:22:44.064771804-07:00] ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock 0  <nil>}] <nil>}  module=grpc
INFO[2020-01-29T07:22:44.064814177-07:00] ClientConn switching balancer to "pick_first"  module=grpc
INFO[2020-01-29T07:22:44.070245283-07:00] parsed scheme: "unix"                         module=grpc
INFO[2020-01-29T07:22:44.070333997-07:00] scheme "unix" not registered, fallback to default scheme  module=grpc
INFO[2020-01-29T07:22:44.070364847-07:00] ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock 0  <nil>}] <nil>}  module=grpc
INFO[2020-01-29T07:22:44.070390331-07:00] ClientConn switching balancer to "pick_first"  module=grpc
WARN[2020-01-29T07:22:44.071893568-07:00] [graphdriver] WARNING: the overlay storage-driver is deprecated, and will be removed in a future release
failed to start daemon: error while opening volume store metadata database: timeout

之后我就什么都做不了了,我已经重新安装了 docker 大约 2 次,但仍然没有任何效果。有人能帮我吗?我正在使用 CentOS 7 发行版。

答案1

我遇到了类似的错误。问题出在 中/etc/systemd/system/docker.service.d/godaddy.conf,有命令运行脚本来配置网络和 iptables:ExecStartPost=/opt/godaddy/docker/configure-snat

在该脚本文件中,对我来说,正是这两行失败了:

...
iptables -t nat -D POSTROUTING -s ${DOCKER_NETWORK} ! -o docker0 -j SNAT --to ${PUBLIC_IP}
iptables -t nat -I POSTROUTING -s ${DOCKER_NETWORK} ! -o docker0 -j SNAT --to ${PUBLIC_IP}

问题出在变量上${PUBLIC_IP},由于某种原因,该变量为空,并且生成的脚本已结束,--too这是错误的,因为--too需要一个参数。因此这会产生错误,导致我的 docker 无法启动。

所以问题不在于docker本身。在我评论了这行之后:#ExecStartPost=/opt/godaddy/docker/configure-snat/etc/systemd/system/docker.service.d/godaddy.conf。问题解决了。就我而言,Docker启动没有任何问题。

答案2

从 /var/lib/docker 中删除文件。然后重新启动 docker 服务。备份图像,因为删除文件夹将删除您的图像数据。

相关内容