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.....。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

天行健,君子以自强不息;地势坤,君子以厚德载物。


每个人都有惰性,但不断学习是好好生活的根本,共勉!


文章均为学习整理笔记,分享记录为主,如有错误请指正,共同学习进步。


一、场景

在搭建Harbor镜像仓库的时候配置insecure-registries参数,需要重启容器,然后重启失败了

二、报错

docker启动命令启动失败

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.

三、分析

1. Docker状态查看

使用命令查看docker状态

systemctl status docker

输出主状态如下,好像也看不出是什么原因

● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2024-01-30 21:14:36 CST; 12h ago
     Docs: https://docs.docker.com
  Process: 4110 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
 Main PID: 4110 (code=exited, status=1/FAILURE)

Jan 30 21:14:36 k8s-master systemd[1]: docker.service: Service RestartSec=2s expired, scheduling restart.
Jan 30 21:14:36 k8s-master systemd[1]: docker.service: Scheduled restart job, restart counter is at 3.
Jan 30 21:14:36 k8s-master systemd[1]: Stopped Docker Application Container Engine.
Jan 30 21:14:36 k8s-master systemd[1]: docker.service: Start request repeated too quickly.
Jan 30 21:14:36 k8s-master systemd[1]: docker.service: Failed with result 'exit-code'.
Jan 30 21:14:36 k8s-master systemd[1]: Failed to start Docker Application Container Engine.

截图
the following directives don't match any configuration option: graph,Debug笔记,# Docker,docker,java,eureka,运维,容器,linux

2. 系统日志查看

然后还可以使用查看系统整体的最后两百行日志

tail -200f /var/log/messages

可能内容多且拥挤所以没找到原因
the following directives don't match any configuration option: graph,Debug笔记,# Docker,docker,java,eureka,运维,容器,linux

3. Dockerd查看

使用dockerd命令查看问题

dockerd

输出如下,这个命令好像能看出一些端倪,感谢某博主的这个dockerd命令,大家可根据输出内容百度查找适合自己的解决方法

unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives don't match any configuration option: insecure-registies

前半段主要原因:unable to configure the Docker daemon with file /etc/docker/daemon.json:
大概意思就是说无法使用daemon.json文件配置docker的守护进程,就是这个json文件的问题
后半段具体原因:the following directives don't match any configuration option: insecure-registies
意思是因为重定向访问无法匹配配置参数insecure-registies,就是这个参数的问题

我的daemon.json文件内容如下:
the following directives don't match any configuration option: graph,Debug笔记,# Docker,docker,java,eureka,运维,容器,linux
到这里应该英文好的施主都能知道问题出在哪里了,我英语差且手残,英文单词registies是错误写法,正确的是registries

如果你跟我这个内容不一样,也是可以参考下面的解决方法

四、解决

1. 键值检查

本篇问题出现在键的单词写错了
正常daemon.json文件的内容是必须符合json格式要求的,且键值一一对应
键一般都是固定的写法,值则根据自己的情况填入
我将insecure-registies修改为正确的insecure-registries
重启docker即解决了这个报错

2. 格式检查

如果你的问题是json文件的问题,但后面写的不是参数问题,键值无误,可检查一下json格式是否正确
将内容复制后粘贴到在线json格式检查网站上检查一下
如果格式错了可修正后重启docker

3. 删除或修改daemon.json文件

如果上面以及网上其他方法都不能解决问题,终极的方法就是这个了,前提是该文件的配置没有了也不会影响你docker的使用
但像我这样在k8s集群中使用的话,里面配置了k8s相关的参数,没有这个文件会影响k8s,就无法使用这个方式解决
方法如下

直接删除daemon.json,命令如下,但不建议这样做

rm -f /etc/docker/daemon.json

为了后续还能改回来使用,可以修改格式使其失效
将daemon.json修改为daemon.text,等同于删除daemon.json

mv /ect/docker/daemon.json /etc/docker/daemon.text

4. 启动Docker

最后重新启动docker

systemctl restart docker

5. 查看Docker

systemctl status docker

the following directives don't match any configuration option: graph,Debug笔记,# Docker,docker,java,eureka,运维,容器,linux

五、演示

完整操作代码

[root@k8s-master ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2024-01-30 21:14:36 CST; 12h ago
     Docs: https://docs.docker.com
  Process: 4110 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
 Main PID: 4110 (code=exited, status=1/FAILURE)

Jan 30 21:14:36 k8s-master systemd[1]: docker.service: Service RestartSec=2s expired, scheduling restart.
Jan 30 21:14:36 k8s-master systemd[1]: docker.service: Scheduled restart job, restart counter is at 3.
Jan 30 21:14:36 k8s-master systemd[1]: Stopped Docker Application Container Engine.
Jan 30 21:14:36 k8s-master systemd[1]: docker.service: Start request repeated too quickly.
Jan 30 21:14:36 k8s-master systemd[1]: docker.service: Failed with result 'exit-code'.
Jan 30 21:14:36 k8s-master systemd[1]: Failed to start Docker Application Container Engine.
[root@k8s-master ~]# 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.
[root@k8s-master ~]# dockerd
unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives don't match any configuration option: insecure-registies
[root@k8s-master ~]# vim /etc/docker/daemon.json
[root@k8s-master ~]# systemctl restart docker
[root@k8s-master ~]# 
[root@k8s-master ~]# 
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2024-01-31 11:26:43 CST; 14s ago
     Docs: https://docs.docker.com
 Main PID: 88041 (dockerd)
    Tasks: 65
   Memory: 66.0M
   CGroup: /system.slice/docker.service
           ├─88041 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
           └─88397 /usr/bin/docker-proxy -proto tcp -host-ip 127.0.0.1 -host-port 1514 -container-ip 172.18.0.8 -container-port 10514

Jan 31 11:26:43 k8s-master dockerd[88041]: time="2024-01-31T11:26:43.379781201+08:00" level=warning msg="Not using native diff for overlay2, this may cause degraded performance for building images: kernel has CONFIG_OVERLAY_FS_REDIRECT_DIR enabled" storage-dr>
Jan 31 11:26:43 k8s-master dockerd[88041]: time="2024-01-31T11:26:43.379956960+08:00" level=info msg="Docker daemon" commit=311b9ff graphdriver=overlay2 version=24.0.7
Jan 31 11:26:43 k8s-master dockerd[88041]: time="2024-01-31T11:26:43.380043382+08:00" level=info msg="Daemon has completed initialization"
Jan 31 11:26:43 k8s-master dockerd[88041]: time="2024-01-31T11:26:43.397548197+08:00" level=info msg="API listen on /run/docker.sock"
Jan 31 11:26:43 k8s-master systemd[1]: Started Docker Application Container Engine.
Jan 31 11:26:56 k8s-master dockerd[88041]: time="2024-01-31T11:26:56.574003576+08:00" level=info msg="ignoring event" container=7d0a423251a913898a85a68efb08ef6a8cd9b02ac614716f8b5041bb18b99125 module=libcontainerd namespace=moby topic=/tasks/delete type="*eve>
Jan 31 11:26:57 k8s-master dockerd[88041]: time="2024-01-31T11:26:57.145364576+08:00" level=info msg="ignoring event" container=56936178be55a27b8daa16f0113c167c15a3a95f79ce4f58aef5b2aabb89b458 module=libcontainerd namespace=moby topic=/tasks/delete type="*eve>
Jan 31 11:26:57 k8s-master dockerd[88041]: time="2024-01-31T11:26:57.282343246+08:00" level=info msg="ignoring event" container=6c8f765580a054d69eac07e2f79dbb33a49165580ae0e542a33d1e0e1e9d38ff module=libcontainerd namespace=moby topic=/tasks/delete type="*eve>
Jan 31 11:26:57 k8s-master dockerd[88041]: time="2024-01-31T11:26:57.447774687+08:00" level=info msg="ignoring event" container=a42115d28e2f7998274f38b0b6235b489beb43adcbca516e6ba964c93d23dada module=libcontainerd namespace=moby topic=/tasks/delete type="*eve>
Jan 31 11:26:57 k8s-master dockerd[88041]: time="2024-01-31T11:26:57.709667843+08:00" level=info msg="ignoring event" container=227806f882531c7b6619dd63a8c16fd29aaf3e3e229c6d10840966bc4b5175c1 module=libcontainerd namespace=moby topic=/tasks/delete type="*eve>


感谢阅读,祝君暴富!文章来源地址https://www.toymoban.com/news/detail-847478.html

到了这里,关于Docker启动失败问题解决:Job for docker.service failed because the control process exited with error code.....的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包