*一次意外的断电致使服务器关机,开机后造成部分docker环境起不来的问题
*于是开始尝试各种方法,共尝试网络的方法四种吧,最后才解决了问题,注意没有重新安装docker。当然也有可能这几种方法适用于你的错误,所以可以尝试一下。
*/
-
报错信息
# docker psCannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
-
重启服务
# systemctl restart 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
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2022-07-08 14:08:08 CST; 5 days ago
Docs: https://docs.docker.com
Process: 979 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=2)
Main PID: 979 (code=exited, status=2)
docker.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
docker.service: Failed with result 'exit-code'.
Failed to start Docker Application Container Engine.
docker.service: Service RestartSec=2s expired, scheduling restart.
docker.service: Scheduled restart job, restart counter is at 3.
Stopped Docker Application Container Engine.
docker.service: Start request repeated too quickly.
docker.service: Failed with result 'exit-code'.
Failed to start Docker Application Container Engine.
-
查看其它信息
# journalctl -xe
解决方案①:
删除”daemon.json“文件
# cd /etc/docker/
# mv daemon.json /home/ #为防止出现重新搞,所以就直接移动了位置
# systemctl daemon-reload
# systemctl restart docker
# 出现卡住不动的情况,所以又把文件移回来了
# mv /home/daemon.json .
##结论:本次尝试失败
解决方案②:
删除.sock文件和.pid文件
# 老规矩,将文件移走
# cd /run/containerd/
# mv containerd.sock /home/
# cd /var/run/
# mv docker.sock docker.pid /home/
# systemctl restart docker
## 结论还是失败,将没有生成的文件移回来
解决方案③:
# systemctl unmask docker
# systemctl start docker
# systemctl status docker
## 感觉好像更严重了
# systemctl unmask docker.service
# systemctl unmask docker.socket
# systemctl start docker.service
##然而并没有解决问题
解决方案④:
# dockerd
# service docker start
## 依然没解决问题
解决方案⑤:
# find /var/lib/docker -type f -size -5M -name '*.db' | grep -v overlay
/var/lib/docker/containerd/daemon/io.containerd.metadata.v1.bolt/meta.db
/var/lib/docker/builder/fscache.db
/var/lib/docker/buildkit/metadata.db
/var/lib/docker/buildkit/snapshots.db
/var/lib/docker/buildkit/cache.db
/var/lib/docker/network/files/local-kv.db
/var/lib/docker/volumes/metadata.db
/var/lib/docker/swarm/worker/tasks.db
# mv /var/lib/docker/network/files/local-kv.db{,.bak}
# systemctl restart docker
# docker 使用了 boltdb 存储了网络信息成 db 文件,但是这个 db 文件损坏了,导致读取字节序列化错误类型
评论(0)