Docker执行命令报错:Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

1、问题说明

Docker执行重新启动命令重启成功。命令如下:

重新加载配置

systemctl daemon-reload

重启 docker 服务

systemctl restart docker.service

查看启动状态 systemctl status docker.service 显示启动成功

使用 docker -v 命令查看版本号输出正常

但是使用 docker ps 命令报错 Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

查看docker启动日志,没有任何报错信息。

journalctl -xe

journalctl -u docker.service --no-pager --lines=50

May 13 16:26:21 iZuf68b75xtsenoqx1k0gdZ dockerd[24284]: time="2024-05-13T16:26:21.886928953+08:00" level=info msg="Daemon shutdown complete"
May 13 16:26:21 iZuf68b75xtsenoqx1k0gdZ systemd[1]: Stopped Docker Application Container Engine.
May 13 16:26:54 iZuf68b75xtsenoqx1k0gdZ systemd[1]: Starting Docker Application Container Engine...
May 13 16:26:54 iZuf68b75xtsenoqx1k0gdZ dockerd[25643]: time="2024-05-13T16:26:54.597594210+08:00" level=info msg="Starting up"
May 13 16:26:54 iZuf68b75xtsenoqx1k0gdZ dockerd[25643]: time="2024-05-13T16:26:54.613636044+08:00" level=info msg="[graphdriver] using prior storage driver: overlay2"
May 13 16:26:54 iZuf68b75xtsenoqx1k0gdZ dockerd[25643]: time="2024-05-13T16:26:54.617172123+08:00" level=info msg="Loading containers: start."
May 13 16:26:54 iZuf68b75xtsenoqx1k0gdZ dockerd[25643]: time="2024-05-13T16:26:54.725761135+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address"
May 13 16:26:55 iZuf68b75xtsenoqx1k0gdZ dockerd[25643]: time="2024-05-13T16:26:55.393570226+08:00" level=info msg="Loading containers: done."
May 13 16:26:55 iZuf68b75xtsenoqx1k0gdZ dockerd[25643]: time="2024-05-13T16:26:55.423986889+08:00" level=info msg="Docker daemon" commit=4ffc614 graphdriver=overlay2 version=24.0.4
May 13 16:26:55 iZuf68b75xtsenoqx1k0gdZ dockerd[25643]: time="2024-05-13T16:26:55.424053881+08:00" level=info msg="Daemon has completed initialization"
May 13 16:26:55 iZuf68b75xtsenoqx1k0gdZ dockerd[25643]: time="2024-05-13T16:26:55.518175497+08:00" level=info msg="API listen on /run/docker.sock"
May 13 16:26:55 iZuf68b75xtsenoqx1k0gdZ systemd[1]: Started Docker Application Container Engine.

2、解决

docker.socket异常退出导致没有退出完成。重新退出docker.socket即可

步骤:

systemctl stop docker.socket

systemctl stop docker

systemctl start docker

启动成功,问题解决。

posted @ 2024-05-13 17:27  sowler  阅读(1593)  评论(0编辑  收藏  举报