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?)
触发此错误的一些原因包括:
我尝试了第3种方法(启动dockerd)解决了这个问题,所以 分享给大家!
如果您刚刚在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