1.问题描述
搭建完成docker registry私有仓库后,在/etc/docker/daemon.json文件中配置完成本地私有仓库信息后,重启docker报错,信息如下:
[root@centos79 ~]# systemctl start docker
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl
[root@centos79 ~]# 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 一 2023-12-11 16:18:05 CST; 1s ago
Docs: https://docs.docker.com
Process: 8273 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
Main PID: 8273 (code=exited, status=1/FAILURE)
12月 11 16:18:05 centos79 systemd[1]: Failed to start Docker Application Container Engine.
12月 11 16:18:05 centos79 systemd[1]: Unit docker.service entered failed state.
12月 11 16:18:05 centos79 systemd[1]: docker.service failed.
[root@centos79 ~]#
2.解决方案
通过排查/etc/docker/daemon.json文件,发现配置错误,即insecure-registries命令少写了字母r,导致启动docker时报上述错误。
更改前:
[root@centos79 ~]# cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://ykjpg821.mirror.aliyuncs.com"],
"insecure-registies": ["172.20.10.12:5000"]
}
[root@centos79 ~]#
更改给:
[root@centos79 ~]# cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://ykjpg821.mirror.aliyuncs.com"],
"insecure-registries": ["172.20.10.12:5000"]
}
[root@centos79 ~]#
另外,如果/etc/docker/daemon.json文件中添加信息,尽量复制原有的配置,然后进行修改更新,否则存在由于存在多余的符号,也会导致docker启动失败。
再次启动docker,发现docker可以正常启动。
[root@centos79 ~]# systemctl daemon-reload
[root@centos79 ~]# systemctl start docker
[root@centos79 ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since 一 2023-12-11 16:30:56 CST; 4s ago
Docs: https://docs.docker.com
Main PID: 8486 (dockerd)
Tasks: 115
Memory: 109.7M
CGroup: /system.slice/docker.service
├─8486 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
├─8658 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 9601 -container-ip 172.18.0.2 -container-port 9600
├─8664 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 9601 -container-ip 172.18.0.2 -container-port 9600
├─8679 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 5045 -container-ip 172.18.0.2 -container-port 5044
├─8687 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 5045 -container-ip 172.18.0.2 -container-port 5044
├─8698 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 9300 -container-ip 172.18.0.4 -container-port 9300
├─8715 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 9300 -container-ip 172.18.0.4 -container-port 9300
├─8722 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 5601 -container-ip 172.18.0.3 -container-port 5601
├─8742 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 5601 -container-ip 172.18.0.3 -container-port 5601
├─8767 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 9600 -container-ip 172.18.0.5 -container-port 9600
├─8772 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 9600 -container-ip 172.18.0.5 -container-port 9600
├─8809 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 9200 -container-ip 172.18.0.4 -container-port 9200
├─8823 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 9200 -container-ip 172.18.0.4 -container-port 9200
├─8845 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 5044 -container-ip 172.18.0.5 -container-port 5044
└─8853 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 5044 -container-ip 172.18.0.5 -container-port 5044
12月 11 16:30:54 centos79 systemd[1]: Starting Docker Application Container Engine...
12月 11 16:30:54 centos79 dockerd[8486]: time="2023-12-11T16:30:54.851847497+08:00" level=info msg="Starting up"
12月 11 16:30:54 centos79 dockerd[8486]: time="2023-12-11T16:30:54.866038451+08:00" level=info msg="[graphdriver] using pri...erlay2"
12月 11 16:30:54 centos79 dockerd[8486]: time="2023-12-11T16:30:54.874397458+08:00" level=info msg="Loading containers: start."
12月 11 16:30:54 centos79 dockerd[8486]: time="2023-12-11T16:30:54.975262507+08:00" level=info msg="Default bridge (docker0...ddress"
12月 11 16:30:55 centos79 dockerd[8486]: time="2023-12-11T16:30:55.875402795+08:00" level=info msg="Loading containers: done."
12月 11 16:30:55 centos79 dockerd[8486]: time="2023-12-11T16:30:55.892186928+08:00" level=info msg="Docker daemon" commit=3...=24.0.7
12月 11 16:30:55 centos79 dockerd[8486]: time="2023-12-11T16:30:55.892234538+08:00" level=info msg="Daemon has completed in...zation"
12月 11 16:30:56 centos79 systemd[1]: Started Docker Application Container Engine.
12月 11 16:30:56 centos79 dockerd[8486]: time="2023-12-11T16:30:56.027556770+08:00" level=info msg="API listen on /run/docker.sock"
Hint: Some lines were ellipsized, use -l to show in full.
[root@centos79 ~]#