Docker配置阿里云镜像报错问题

一 按照阿里云docker镜像配置方法配置docker的镜像,出现如下报错

[root@centos docker]# tee /etc/docker/daemon.json <<-'EOF'
> {
>   "registry-mirrors": ["https://48yz3v3v.mirror.aliyuncs.com"]
> }
> EOF
{
  "registry-mirrors": ["https://48yz3v3v.mirror.aliyuncs.com"]
}
[root@centos docker]# systemctl daemon-reload
[root@centos docker]# systemctl restart 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@centos docker]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/etc/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: failed (Result: start-limit) since Fri 2020-10-09 21:30:04 CST; 1min 11s ago
     Docs: https://docs.docker.com
  Process: 15511 ExecStart=/usr/bin/dockerd --registry-mirror=https://48yz3v3v.mirror.aliyuncs.com (code=exited, status=1/FAILURE)
Main PID: 15511 (code=exited, status=1/FAILURE)

Oct 09 21:30:04 centos systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Oct 09 21:30:04 centos systemd[1]: Failed to start Docker Application Container Engine.
Oct 09 21:30:04 centos systemd[1]: Unit docker.service entered failed state.
Oct 09 21:30:04 centos systemd[1]: docker.service failed.
Oct 09 21:30:04 centos systemd[1]: docker.service holdoff time over, scheduling restart.
Oct 09 21:30:04 centos systemd[1]: Stopped Docker Application Container Engine.
Oct 09 21:30:04 centos systemd[1]: start request repeated too quickly for docker.service
Oct 09 21:30:04 centos systemd[1]: Failed to start Docker Application Container Engine.
Oct 09 21:30:04 centos systemd[1]: Unit docker.service entered failed state.
Oct 09 21:30:04 centos systemd[1]: docker.service failed.
[root@centos docker]# rm daemon.json
rm: remove regular file ‘daemon.json’? y
[root@centos docker]# systemctl daemon-reload
[root@centos docker]# systemctl restart docker

重点关注下面两点:

1 报错文件

/etc/systemd/system/docker.service

2 报错信息

Process: 15511 ExecStart=/usr/bin/dockerd --registry-mirror=https://48yz3v3v.mirror.aliyuncs.com (code=exited, status=1/FAILURE) 

三 查看 /etc/systemd/system/docker.service 文件

[root@centos docker]# cat /etc/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 --registry-mirror=https://48yz3v3v.mirror.aliyuncs.com
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

这里提到了 ExecStart=/usr/bin/dockerd --registry-mirror=https://48yz3v3v.mirror.aliyuncs.com,这句话告诉我们启动后,使用该地址作为镜像加速,其实已经配置了镜像加速。所以无需再配置镜像加速了。

在两个地方都配置镜像加速,系统冲突报错。我们只需配置一个地方即可。

四 配置镜像加速有很多方法,具体参考下面博客,总有一种方式可以配置成功

https://blog.csdn.net/h4241778/article/details/108901890

猜你喜欢

转载自blog.csdn.net/chengqiuming/article/details/108987083