如何覆盖docker.service文件中的配置,解决一次docker.service启动不成功的问题

一、问题

服务器重启之后systemctl restart docker始终不成功,网上各种方法都试了一遍,依然没有解决问题。

systemctl restart docker 报错信息:

[root@localhost xs-2.0]# systemctl start docker
Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xe" for details.

systemctl status docker.service  查看错误信息:

[root@localhost xs-2.0]# systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/etc/systemd/system/docker.service; disabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/docker.service.d
           └─docker.conf
   Active: failed (Result: exit-code) since Tue 2022-08-16 12:37:33 CST; 36s ago
     Docs: https://docs.docker.com
  Process: 394313 ExecStart=/usr/bin/dockerd --default-ulimit nofile=65535:65535 -H fd:// (code=exited, status=1/FAILURE)
 Main PID: 394313 (code=exited, status=1/FAILURE)

8月 16 12:37:33 localhost.localdomain systemd[1]: docker.service: Service RestartSec=100ms expired, scheduling restart.
8月 16 12:37:33 localhost.localdomain systemd[1]: docker.service: Scheduled restart job, restart counter is at 3.
8月 16 12:37:33 localhost.localdomain systemd[1]: Stopped Docker Application Container Engine.
8月 16 12:37:33 localhost.localdomain systemd[1]: docker.service: Start request repeated too quickly.
8月 16 12:37:33 localhost.localdomain systemd[1]: docker.service: Failed with result 'exit-code'.
8月 16 12:37:33 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.

journalctl -xe 查看报错详细信息:

[root@localhost xs-2.0]# journalctl -xe
--
-- An ExecStart= process belonging to unit docker.service has exited.
--
-- The process' exit code is 'exited' and its exit status is 1.
8月 16 12:37:32 localhost.localdomain systemd[1]: docker.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The unit docker.service has entered the 'failed' state with result 'exit-code'.
8月 16 12:37:32 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
-- Subject: docker.service 单元已失败
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- docker.service 单元已失败。
--
-- 结果为“failed”。
8月 16 12:37:32 localhost.localdomain audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=docker comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed'
8月 16 12:37:32 localhost.localdomain auditd[1141]: find kylin-root
8月 16 12:37:32 localhost.localdomain auditd[1141]: AUDIT:bfree=500118,threshold_size=75,fs_space_warning=0
8月 16 12:37:33 localhost.localdomain systemd[1]: docker.service: Service RestartSec=100ms expired, scheduling restart.
8月 16 12:37:33 localhost.localdomain 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: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Automatic restarting of the unit docker.service has been scheduled, as the result for
-- the configured Restart= setting for the unit.
8月 16 12:37:33 localhost.localdomain systemd[1]: Stopped Docker Application Container Engine.
-- Subject: docker.service 单元已结束停止操作
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- docker.service 单元已结束停止操作。
8月 16 12:37:33 localhost.localdomain audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=docker comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
8月 16 12:37:33 localhost.localdomain audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=docker comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
8月 16 12:37:33 localhost.localdomain systemd[1]: docker.service: Start request repeated too quickly.
8月 16 12:37:33 localhost.localdomain systemd[1]: docker.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The unit docker.service has entered the 'failed' state with result 'exit-code'.
8月 16 12:37:33 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
-- Subject: docker.service 单元已失败
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- docker.service 单元已失败。
--
-- 结果为“failed”。
8月 16 12:37:33 localhost.localdomain auditd[1141]: find kylin-root
8月 16 12:37:33 localhost.localdomain auditd[1141]: AUDIT:bfree=500118,threshold_size=75,fs_space_warning=0
8月 16 12:37:33 localhost.localdomain auditd[1141]: find kylin-root
8月 16 12:37:33 localhost.localdomain auditd[1141]: AUDIT:bfree=500118,threshold_size=75,fs_space_warning=0
lines 1895-1950/1950 (END)

vi /var/log/messages 查看日志,shift+G定位到末尾,具体报错信息:

Aug 16 12:37:32 localhost systemd[1]: Starting Docker Application Container Engine...
Aug 16 12:37:32 localhost dockerd[394274]: time="2022-08-16T12:37:32.368689600+08:00" level=info msg="Starting up"
Aug 16 12:37:32 localhost dockerd[394274]: failed to load listeners: no sockets found via socket activation: make sure the service was started by systemd
Aug 16 12:37:32 localhost systemd[1]: docker.service: Main process exited, code=exited, status=1/FAILURE
Aug 16 12:37:32 localhost systemd[1]: docker.service: Failed with result 'exit-code'.
Aug 16 12:37:32 localhost systemd[1]: Failed to start Docker Application Container Engine.
Aug 16 12:37:32 localhost audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=docker comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed'
Aug 16 12:37:32 localhost auditd[1141]: find kylin-root
Aug 16 12:37:32 localhost auditd[1141]: AUDIT:bfree=500118,threshold_size=75,fs_space_warning=0
Aug 16 12:37:32 localhost systemd[1]: docker.service: Service RestartSec=100ms expired, scheduling restart.
Aug 16 12:37:32 localhost systemd[1]: docker.service: Scheduled restart job, restart counter is at 1.
Aug 16 12:37:32 localhost systemd[1]: Stopped Docker Application Container Engine.
Aug 16 12:37:32 localhost audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=docker comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Aug 16 12:37:32 localhost audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=docker comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Aug 16 12:37:32 localhost systemd[1]: Starting Docker Application Container Engine...
Aug 16 12:37:32 localhost dockerd[394298]: time="2022-08-16T12:37:32.602459047+08:00" level=info msg="Starting up"
Aug 16 12:37:32 localhost dockerd[394298]: failed to load listeners: no sockets found via socket activation: make sure the service was started by systemd
Aug 16 12:37:32 localhost systemd[1]: docker.service: Main process exited, code=exited, status=1/FAILURE
Aug 16 12:37:32 localhost systemd[1]: docker.service: Failed with result 'exit-code'.
Aug 16 12:37:32 localhost systemd[1]: Failed to start Docker Application Container Engine.
Aug 16 12:37:32 localhost audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=docker comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed'
Aug 16 12:37:32 localhost systemd[1]: docker.service: Service RestartSec=100ms expired, scheduling restart.
Aug 16 12:37:32 localhost systemd[1]: docker.service: Scheduled restart job, restart counter is at 2.
Aug 16 12:37:32 localhost systemd[1]: Stopped Docker Application Container Engine.
Aug 16 12:37:32 localhost audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=docker comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Aug 16 12:37:32 localhost audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=docker comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Aug 16 12:37:32 localhost auditd[1141]: find kylin-root
Aug 16 12:37:32 localhost auditd[1141]: AUDIT:bfree=500118,threshold_size=75,fs_space_warning=0
Aug 16 12:37:32 localhost auditd[1141]: find kylin-root
Aug 16 12:37:32 localhost auditd[1141]: AUDIT:bfree=500118,threshold_size=75,fs_space_warning=0
Aug 16 12:37:32 localhost systemd[1]: Starting Docker Application Container Engine...
Aug 16 12:37:32 localhost dockerd[394313]: time="2022-08-16T12:37:32.853072407+08:00" level=info msg="Starting up"
Aug 16 12:37:32 localhost dockerd[394313]: failed to load listeners: no sockets found via socket activation: make sure the service was started by systemd
Aug 16 12:37:32 localhost systemd[1]: docker.service: Main process exited, code=exited, status=1/FAILURE
Aug 16 12:37:32 localhost systemd[1]: docker.service: Failed with result 'exit-code'.
Aug 16 12:37:32 localhost systemd[1]: Failed to start Docker Application Container Engine.

关键报错信息:

failed to load listeners: no sockets found via socket activation: make sure the service was started by systemd

二、解决

在网上找了各种解决方案,都没有解决问题。

大多都是让修改docker.service文件中的配置,但是很遗憾我的始终不起作用。

后面看到一篇博客说可以覆盖docker.service中的配置,于是尝试自己创建override配置文件,最终成功解决问题。

具体步骤:

vi /etc/systemd/system/docker.service.d/override.conf

如果目录不存在,先手动创建目录

override.conf中输入:

# Disable flags to dockerd, all settings are done in /etc/docker/daemon.json
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd
systemctl daemon-reload
systemctl restart docker

启动成功

  • 10
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值