systemctl start docker失败原因

本文详细解析了Docker服务启动失败的问题,特别是在使用自定义daemon.json配置文件时与systemd启动参数冲突的情况。通过调整docker.service配置,成功解决了Docker无法启动的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

背景:

使用自配置文件 /etc/docker/daemon.json

systemctl enable docker.service将docker加入服务

 

问题:

dockerd可以正常启动,但是systemctl start 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.

使用journalctl -xe查看具体原因:

1月 24 08:19:15 vultr.guest 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.
1月 24 08:19:15 vultr.guest dockerd[3471]: unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as a flag and in the
1月 24 08:19:15 vultr.guest systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
1月 24 08:19:15 vultr.guest systemd[1]: Failed to start Docker Application Container Engine.
-- 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.
1月 24 08:19:15 vultr.guest systemd[1]: Unit docker.service entered failed state.
1月 24 08:19:15 vultr.guest systemd[1]: docker.service failed.
1月 24 08:19:17 vultr.guest systemd[1]: docker.service holdoff time over, scheduling restart.
1月 24 08:19:17 vultr.guest systemd[1]: Stopped Docker Application Container Engine.
-- Subject: Unit docker.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.service has finished shutting down.
1月 24 08:19:17 vultr.guest 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.
1月 24 08:19:17 vultr.guest dockerd[3475]: unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as a flag and in the
1月 24 08:19:17 vultr.guest systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
1月 24 08:19:17 vultr.guest systemd[1]: Failed to start Docker Application Container Engine.
-- Subject: Unit docker.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.service has failed.

 

实际上,上述最重要的是

unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as a flag and in the

搜官网(https://docs.docker.com/config/daemon/),可以知道,是由于自配置的deamon.json和自动启动参数冲突。由于是systemctl启动,因此查看 /usr/lib/systemd/system/docker.service中的ExecStart项,发现其后面多了一句 -H unix:/,而我们的daemon.json指定了host。因此冲突。

 

将其删除即可。

 

systemctl daemon-reload

systemctl start docker.service

问题解决。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值