一、前言
1、首先明确是否修改过配置文件,多数启动失败是修改过配置文件的原因(本文是修改过配置文件但未重启Docker服务,导致重启系统后Docker服务启动失败)
2、如果不明确是否修改过配置文件,可查询docker日志是否出现报错,日志路径是/var/log/messages
tail -f /var/log/messages
报错如下,提示/etc/docker/daemon.json文件有问题
Jun 26 10:17:48 hecs-366931 systemd: Starting Docker Application Container Engine...
Jun 26 10:17:48 hecs-366931 dockerd: unable to configure the Docker daemon with file /etc/docker/daemon.json: invalid character '}' looking for beginning of object key string
二、Docker启动失败,根据报错查看镜像源配置文件/etc/docker/daemon.json
检查配置文件,发现json语法错误,"]"后面需要加个","
{
"storage-driver":"devicemapper",
"storage-opts":[
"dm.thinpooldev=/dev/mapper/vgpaas-thinpool",
"dm.use_deferred_removal=true",
"dm.fs=ext4",
"dm.use_deferred_deletion=true",
"dm.basesize=10G"
]
"insecure-registries":["docker.codedev.top:88","registry.cn-hangzhou.aliyuncs.com"]
}
修改配置文件并保存,重启Docker服务正常,问题解决
{
"storage-driver":"devicemapper",
"storage-opts":[
"dm.thinpooldev=/dev/mapper/vgpaas-thinpool",
"dm.use_deferred_removal=true",
"dm.fs=ext4",
"dm.use_deferred_deletion=true",
"dm.basesize=10G"
],
"insecure-registries":["docker.codedev.top:88","registry.cn-hangzhou.aliyuncs.com"]
}
最后一次更新于2023-06-26
0 条评论