Cannot Connect to the Docker Daemon at ‘unix:///var/run/docker.sock’ 出坑方法,已经解决了

docker安装后,使用中经常出现的错误是:

Cannot connect to the Docker daemon at (unix:///var/run/docker.sock. Is the docker daemon running?) 

Cannot connect to the Docker daemon at (unix:///var/run/docker.sock. Is the docker daemon running?) 

一、什么原因导致的:

触发此错误的一些原因包括:

  • The Docker daemon is not running.   Docker守护程序未运行。
  • Docker doesn’t shutdown cleanly.       Docker无法完全关闭。
  • Lack of root privileges to start the docker service.   缺少启动docker服务的root权限。

              我尝试了第3种方法(启动dockerd)解决了这个问题,所以 分享给大家!

二、各种可能的解决方案。

解决方法1:使用systemctl命令   (Start the Docker service with systemctl)

如果您刚刚在Ubuntu上完成了Docker的新安装或重新启动了PC,那么很有可能Docker服务没有运行( there is a high probability chance the Docker service is not running. )。Docker守护程序(dockerd)是Docker的系统服务。该服务处理各种Docker对象,如图像、容器、网络和卷,并侦听Docker API请求。

Systemctl命令用来取代旧的SysV init系统,它管理在Linux系统上运行的systemd服务。

注意:此方法仅适用于使用APT包管理器安装Docker的用户。如果您通过SNAP安装了Docker,请参阅下面的解决方法5。

(1)在终端中执行 – unmask docker.

sudo systemctl unmask docker

如果docker被masked了,一般会有这样的提示:‘Failed to start docker.service: Unit is masked.’ 

(2)启动 start the docker daemon


你可能感兴趣的:(docker,ubuntu,unix)