解决:Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?(服务器重启后dockers没有启动起来)

阿王 2022-09-21 01:54:25 17483 0 0 0

今天重启服务器时报了:Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

翻译过来就是:无法连接到Docker守护进程在unix:///var/run/ Docker .sock。docker守护进程正在运行吗?
这个主要的问题就是docker没有启动起来导致的…

[root@iZ2zecdh933ojcl6vikvdaZ ~]# docker images
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

启动docker并查看运行状态是否成功–

[root@iZ2zecdh933ojcl6vikvdaZ ~]# systemctl start docker
[root@iZ2zecdh933ojcl6vikvdaZ ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since 三 2022-09-21 09:45:24 CST; 14s ago
     Docs: https://docs.docker.com
 Main PID: 7213 (dockerd)
    Tasks: 14
   Memory: 117.7M
   CGroup: /system.slice/docker.service
           └─7213 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

9月 21 09:45:23 iZ2zecdh933ojcl6vikvdaZ dockerd[7213]: time="2022-09-21T09:45:23.382212965+08:00" level=info msg="ccResolverWrapper: sending update to cc: {[...dule=grpc
9月 21 09:45:23 iZ2zecdh933ojcl6vikvdaZ dockerd[7213]: time="2022-09-21T09:45:23.382221855+08:00" level=info msg="ClientConn switching balancer to \"pick_fir...dule=grpc
9月 21 09:45:23 iZ2zecdh933ojcl6vikvdaZ dockerd[7213]: time="2022-09-21T09:45:23.677629700+08:00" level=info msg="[graphdriver] using prior storage driver: overlay2"
9月 21 09:45:23 iZ2zecdh933ojcl6vikvdaZ dockerd[7213]: time="2022-09-21T09:45:23.922319739+08:00" level=info msg="Loading containers: start."
9月 21 09:45:24 iZ2zecdh933ojcl6vikvdaZ dockerd[7213]: time="2022-09-21T09:45:24.142924990+08:00" level=info msg="Default bridge (docker0) is assigned with a... address"
9月 21 09:45:24 iZ2zecdh933ojcl6vikvdaZ dockerd[7213]: time="2022-09-21T09:45:24.181340154+08:00" level=info msg="Loading containers: done."
9月 21 09:45:24 iZ2zecdh933ojcl6vikvdaZ dockerd[7213]: time="2022-09-21T09:45:24.292501940+08:00" level=info msg="Docker daemon" commit=e42327a graphdriver(s...=20.10.18
9月 21 09:45:24 iZ2zecdh933ojcl6vikvdaZ dockerd[7213]: time="2022-09-21T09:45:24.292977277+08:00" level=info msg="Daemon has completed initialization"
9月 21 09:45:24 iZ2zecdh933ojcl6vikvdaZ systemd[1]: Started Docker Application Container Engine.
9月 21 09:45:24 iZ2zecdh933ojcl6vikvdaZ dockerd[7213]: time="2022-09-21T09:45:24.313332945+08:00" level=info msg="API listen on /var/run/docker.sock"
Hint: Some lines were ellipsized, use -l to show in full.

看到running的标志,就是运行成功了…
或者运行一个docket的命令比如
docker ps

为了避免日后重启再次出现类似情况,增加一个开机自动启动docker…

[root@iZ2zecdh933ojcl6vikvdaZ ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.