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
啟動成功,問題解決。