Docker启动报错unable to configure the Docker daemon with file daemon.json:cannot unmarshal s…[]错误解决

服务器(CentOS)重启后,发现Docker启动不起来了

[root@iZ2ze9d5m6vjfbqzb49i5qZ ~]# 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.

按照提示,使用systemctl status docker.service查看容器状态

[root@iZ2ze9d5m6vjfbqzb49i5qZ ~]# sudo 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: exit-code) since Thu 2022-01-06 17:29:31 CST; 11s ago
     Docs: http://docs.docker.com
  Process: 2711 ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --init-path=/usr/libexec/docker/docker-init-current --seccomp-profile=/etc/docker/seccomp.json $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY $REGISTRIES (code=exited, status=1/FAILURE)
 Main PID: 2711 (code=exited, status=1/FAILURE)

Jan 06 17:29:31 iZ2ze9d5m6vjfbqzb49i5qZ systemd[1]: Starting Docker Application Container Engine...
Jan 06 17:29:31 iZ2ze9d5m6vjfbqzb49i5qZ dockerd-current[2711]: unable to configure the Docker daemon with file /etc/docker/daemon.json: json: cannot unmarshal s...[]string
Jan 06 17:29:31 iZ2ze9d5m6vjfbqzb49i5qZ systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Jan 06 17:29:31 iZ2ze9d5m6vjfbqzb49i5qZ systemd[1]: Failed to start Docker Application Container Engine.
Jan 06 17:29:31 iZ2ze9d5m6vjfbqzb49i5qZ systemd[1]: Unit docker.service entered failed state.
Jan 06 17:29:31 iZ2ze9d5m6vjfbqzb49i5qZ systemd[1]: docker.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

发现关键报错,unable to configure the Docker daemon with file /etc/docker/daemon.json: json: cannot unmarshal s…[]string,但是好像又没有显示全,加上-l参数查看详细信息

[root@iZ2ze9d5m6vjfbqzb49i5qZ ~]# sudo systemctl status docker.service -l
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2022-01-06 17:34:12 CST; 22s ago
     Docs: http://docs.docker.com
  Process: 2773 ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --init-path=/usr/libexec/docker/docker-init-current --seccomp-profile=/etc/docker/seccomp.json $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY $REGISTRIES (code=exited, status=1/FAILURE)
 Main PID: 2773 (code=exited, status=1/FAILURE)

Jan 06 17:34:12 iZ2ze9d5m6vjfbqzb49i5qZ systemd[1]: Starting Docker Application Container Engine...
Jan 06 17:34:12 iZ2ze9d5m6vjfbqzb49i5qZ dockerd-current[2773]: unable to configure the Docker daemon with file /etc/docker/daemon.json: json: cannot unmarshal string into Go struct field Config.registry-mirrors of type []string
Jan 06 17:34:12 iZ2ze9d5m6vjfbqzb49i5qZ systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Jan 06 17:34:12 iZ2ze9d5m6vjfbqzb49i5qZ systemd[1]: Failed to start Docker Application Container Engine.
Jan 06 17:34:12 iZ2ze9d5m6vjfbqzb49i5qZ systemd[1]: Unit docker.service entered failed state.
Jan 06 17:34:12 iZ2ze9d5m6vjfbqzb49i5qZ systemd[1]: docker.service failed.

发现了关键报错信息,我们配置的docker镜像写法错误

unable to configure the Docker daemon with file /etc/docker/daemon.json: json: cannot unmarshal string into Go struct field Config.registry-mirrors of type []string

Docker启动报错unable to configure the Docker daemon with file daemon.json:cannot unmarshal s…[]错误解决
于是修改daemon.json配置文件

vi /etc/docker/daemon.json

之前的写法为:

{"registry-mirrors":"https://docker.mirrors.ustc.edu.cn","live-restore":true}

修改后为

{"registry-mirrors":["https://docker.mirrors.ustc.edu.cn"],"live-restore":true}

错误解决
Docker启动报错unable to configure the Docker daemon with file daemon.json:cannot unmarshal s…[]错误解决

上一篇:Linux关闭avahi-daemon服务


下一篇:kubenetes-控制器DaemonSet