解决docker服务无法重启,报错loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)

执行docker服务重启systemctl restart docker.service命令后,服务未正常启动,查看docker服务的状态,报loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)。
错误如下:

[root@localhost ~]# systemctl start docker.service  
Job for docker.service failed because start of the service was attempted too often. See "systemctl status docker.service" and "journalctl -xe" for details.
To force a start use "systemctl reset-failed docker.service" followed by "systemctl start docker.service" again.
[root@localhost ~]# systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: failed (Result: start-limit) since Mo 2020-06-08 10:59:41 CST; 1min 44s ago
     Docs: https://docs.docker.com
  Process: 12296 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
 Main PID: 12296 (code=exited, status=1/FAILURE)

Jun 08 10:59:41 localhost.localdomain systemd[1]: start request repeated too quickly for docker.service
Jun 08 10:59:41 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
Jun 08 10:59:41 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
Jun 08 10:59:41 localhost.localdomain systemd[1]: docker.service failed.
Jun 08 11:00:06 localhost.localdomain systemd[1]: start request repeated too quickly for docker.service
Jun 08 11:00:06 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
Jun 08 11:00:06 localhost.localdomain systemd[1]: docker.service failed.
Jun 08 11:00:25 localhost.localdomain systemd[1]: start request repeated too quickly for docker.service
Jun 08 11:00:25 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
Jun 08 11:00:25 localhost.localdomain systemd[1]: docker.service failed.

解决办法:

1、检查/etc/docker/daemon.json文件配置是否正确。
格式如下:

[root@localhost ~]# cat /etc/docker/daemon.json 
{
   "insecure-registries":["11.1.14.145:8080"],
   "hosts": ["tcp://127.0.0.1:2375", "unix:///var/run/docker.sock"]
}

2、检查/usr/lib/systemd/system/docker.service文件是否正常。
内容如下:

[root@localhost ~]# cat /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd 
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s

[Install]
WantedBy=multi-user.target

你可能感兴趣的:(解决docker服务无法重启,报错loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled))