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
发表评论