关闭docker后,执行systemctl start docker命令后,服务未正常启动,查看docker状态,报:Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
如下:
[root@zhaodong-centos system]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: activating (auto-restart) (Result: exit-code) since Mon 2021-03-15 19:46:33 CST; 546ms ago
Docs: https://docs.docker.com
Process: 2660 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
Main PID: 2660 (code=exited, status=1/FAILURE)
Mar 15 19:46:33 zhaodong-centos systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Mar 15 19:46:33 zhaodong-centos systemd[1]: Failed to start Docker Application Container Engine.
Mar 15 19:46:33 zhaodong-centos systemd[1]: Unit docker.service entered failed state.
Mar 15 19:46:33 zhaodong-centos systemd[1]: docker.service failed.
解决办法
1、检查 /etc/docker/daemon.jsno
文件配置是否正确,必须是json格式!
[root@zhaodong-centos system]# cat /etc/docker/daemon.json
{
"registry-mirrors": [
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn"
"https://omh8vcpy.mirror.aliyuncs.com"
]
}
2、检查 /usr/lib/systemd/system/docker.service
文件是否配置正常
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
BindsTo=containerd.service
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket
[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 -H fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3
# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s
# 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
# Comment TasksMax if your systemd version does not support it.
# Only systemd 226 and above support this option.
TasksMax=infinity
# 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
[Install]
WantedBy=multi-user.target