版本信息:centos7、docker19.03.2(使用阿里镜像源下载的)
在使用sudo systemctl start docker命令启动docker时失败。
[vagrant@localhost ~]$ sudo 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.
日志信息:
[vagrant@localhost ~]$ systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: failed (Result: start-limit) since Mon 2021-07-05 12:22:19 UTC; 4s ago
Docs: https://docs.docker.com
Process: 1191 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
Main PID: 1191 (code=exited, status=1/FAILURE)
Jul 05 12:22:17 localhost.localdomain systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Jul 05 12:22:17 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
Jul 05 12:22:17 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
Jul 05 12:22:17 localhost.localdomain systemd[1]: docker.service failed.
Jul 05 12:22:19 localhost.localdomain systemd[1]: docker.service holdoff time over, scheduling restart.
Jul 05 12:22:19 localhost.localdomain systemd[1]: Stopped Docker Application Container Engine.
Jul 05 12:22:19 localhost.localdomain systemd[1]: start request repeated too quickly for docker.service
Jul 05 12:22:19 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
Jul 05 12:22:19 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
Jul 05 12:22:19 localhost.localdomain systemd[1]: docker.service failed.
解决方法:
在docker.service文件中加入阿里的镜像源。
- cd /usr/lib/systemd/system
- sudo vi docker.service
- 修改ExecStart后的值
[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
ExecStart=/usr/bin/dockerd --registry-mirror=https://ceqq2s09.mirror.aliyuncs.com
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
搞定~