解决docker启动失败Failed to start containerd container runtime
作者:胖胖胖胖胖虎
docker启动失败Failed to start containerd container runtime
[root@hadoop03 ~]# service docker start Redirecting to /bin/systemctl start docker.service A dependency job for docker.service failed. See 'journalctl -xe' for details.
[root@hadoop03 ~]# journalctl -xe ... containerd.service: main process exited, code=exited, status=2/INVALIDARGUMENT Failed to start containerd container runtime. ...
https://github.com/containerd/containerd/issues/5175
[root@hadoop03 ~]# yum remove containerd.io [reboot] [root@hadoop03 ~]# yum install docker-ce
docker镜像container启动失败处理
1.非正常关闭造成启动失败处理
例如容器id为 3c252b492c5c
1)docker stop 3c252b492c5c
停止失败,强制结束,此时显示运行中却无法登录
报错如下
Error response from daemon: mkdir /var/run/docker/libcontainerd/containerd/3c252b492c5c697ac06a1e2b708dc679b31765f360f2aa185cebb2a4f298d90d: file exists
Error: failed to start containers: 3c252b492c5c
2)ps -aux|grep 3c252b492c5c
查看CONTAINER对应的进程id为17933
3)kill -9 17933
强制杀掉进程,用kill无法杀死
4)docker start 3c252b492c5c
启动成功
2.重启报错:container with id exists
Docker重新启动问题
如果重新启动服务器,或者docker异常终止,例如
kill -9 {DOCKER_PID}
那么重新启动容器时可能会出错。
docker restart 2dc3fc6e5e3e
问题报错如下:
Error response from daemon: Cannot restart container 2dc3fc6e5e3e: oci runtime error: container with id exists: 2dc3fc6e5e3e5b63c9d3ad8074972b72867b9ccd250b4c7fced42c616adc2070
Docker inspect 2dc3fc6e5e3e
确认容器文件位置
解决方案是从runc和containerd中移除容器,移动到其他目录
#mkdir /root/runc #mv /run/runc/2dc3fc6e5e3e5b63c9d3ad8074972b72867b9ccd250b4c7fced42c616adc2070 /root/runc/2dc3fc6e5e3e5b63c9d3ad8074972b72867b9ccd250b4c7fced42c616adc2070.bak #mv /run/containerd/2dc3fc6e5e3e5b63c9d3ad8074972b72867b9ccd250b4c7fced42c616adc2070 /root/containerd/2dc3fc6e5e3e5b63c9d3ad8074972b72867b9ccd250b4c7fced42c616adc2070.bak
某些版本无/run/containerd/
docker start 2dc3fc6e5e3e
启动容器,确认状态及运行情况,等稳定后可考虑删除原文件
rm -rf /root/runc/2dc3fc6e5e3e5b63c9d3ad8074972b72867b9ccd250b4c7fced42c616adc2070.bak rm -rf /root/containerd/2dc3fc6e5e3e5b63c9d3ad8074972b72867b9ccd250b4c7fced42c616adc2070.bak
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。