Docker报错Job for docker.service failed because the control process exited with error code.
配置加速镜像之后启动docker一直报错
Job for docker.service failed because the control process exited with error code. See “systemctl status docker.service” and “journalctl -xe” for details.
查看docker状态之后显示如下信息
83906 ExecStart=/usr/bin/dockerd $DOCKER_OPTS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $DOCKER_DNS_OPTIONS $INSECURE_REGISTRY (code=exited, status=1/FAILURE)
错误原因:
docker的socket配置出现了冲突,docker在运行时的启动入口文件为:/lib/systemd/system/docker.service,我们在配置镜像加速之后又添加了一个守护进程文件:/etc/docker/daemon.json,两个文件对host进行了配置,发生冲突。
解决办法
①首先查看/etc/docker/daemon.json文件的配置信息是否正确
{
"registry-mirrors":["http://hub-mirror.c.163.com"]
}
修改完成保存退出即可,重新加载daemon.json
systemctl daemon-reload
启动:docker查看
systemctl start docker
②将加速器地址添加到配置文件的启动命令即可
备份docker.service文件
cp /lib/systemd/system/docker.service /etc/systemd/system/docker.service
将镜像加速器地址添加到docker的启动命令
sed -i "s|ExecStart=/usr/bin/docker daemon|ExecStart=/usr/bin/docker daemon --registry-mirror=自己的镜像地址|g" /etc/systemd/system/docker.service
本文中配置的是网易的镜像加速,修改命令为,复制执行即可
sed -i "s|ExecStart=/usr/bin/docker daemon|ExecStart=/usr/bin/docker daemon --registry-mirror={http://hub-mirror.c.163.com|g" /etc/systemd/system/docker.servic
然后重新加载daemon.json,再启动docker即可
systemctl daemon-reload
systemctl start docker
③(尝试了这个方式,没有成功,方法②确定正确)将docker启动入口文件中的-H fd://删除再重启服务,或者在启动入口配置监听的端口和本地socket信息:
vim /lib/systemd/system/docker.service
将ExecStart=/usr/bin/dockerd -H fd:// $DOCKER_OPTS改为
ExecStart=/usr/bin/dockerd
或改为
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
最后启动或者重启docker即可
上一篇: Elasticsearch启动报错
下一篇: WebService
推荐阅读
-
Linux系统Docker启动问题Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service"
-
Centos7 网络报错Job for iptables.service failed because the control process exited with error code.
-
Docker启动报错:Job for docker.service failed because the control process exited with error code.
-
启动Jenkins服务报错:Job for jenkins.service failed because the control process exited with error code
-
centos7 docker 启动失败 报错【Job for docker.service failed because the control process exited with error】
-
Centos7 网络报错Job for iptables.service failed because the control process exited with error code.
-
Linux系统Docker启动问题Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service"
-
Docker报错Job for docker.service failed because the control process exited with error code.