当我把Docker版本更新到0.8.0后,我在输入sudo Docker version时得到了一个错误消息:

Client version: 0.8.0
Go version (client): go1.2
Git commit (client): cc3a8c8
2014/02/19 12:54:16 Can't connect to docker daemon. Is 'docker -d' running on this host?

我按照说明,输入命令sudo docker -d,我得到了这个:

[/var/lib/docker|2462000b] +job initserver()
[/var/lib/docker|2462000b.initserver()] Creating server
open /var/lib/docker/aufs/layers/cf2414da53f9bcfaa48bc3d58360d7f1cfd3784e4fe51fbef95197709dfc285d: no such file or directory[/var/lib/docker|2462000b] -job initserver() = ERR (1)
2014/02/19 12:55:57 initserver: open /var/lib/docker/aufs/layers/cf2414da53f9bcfaa48bc3d58360d7f1cfd3784e4fe51fbef95197709dfc285d: no such file or directory

我怎么解决这个问题?


当前回答

如果上面所有的解决方案都不起作用,你可以尝试检查/var/run/docker.sock的所有权:

ls -l /var/run/docker.sock

如果你不是所有者,那么使用以下命令改变所有者:

sudo chown *your-username* /var/run/docker.sock

然后,您可以继续尝试轻松地执行Docker命令

其他回答

检查你是否正在使用Docker Machine:)

运行docker-machine env default就可以了。

因为根据文档:

Docker Machine is a tool that lets you install Docker Engine on virtual hosts, and manage the hosts with docker-machine commands. You can use Machine to create Docker hosts on your local Mac or Windows box, on your company network, in your data center, or on cloud providers like AWS or Digital Ocean. Using docker-machine commands, you can start, inspect, stop, and restart a managed host, upgrade the Docker client and daemon, and configure a Docker client to talk to your host. Point the Machine CLI at a running, managed host, and you can run docker commands directly on that host. For example, run docker-machine env default to point to a host called default, follow on-screen instructions to complete env setup, and run docker ps, docker run hello-world, and so forth.

https://docs.docker.com/machine/overview/

已经有很多答案了,但希望这能帮助到一些人。这是通过snap安装docker时出现的问题。通过sudo运行将允许您连接到守护进程,但这将导致其他问题。解决方案是在安装snap包之前执行以下步骤:

sudo addgroup --system docker
sudo adduser $USER docker
newgrp docker
sudo snap install docker

在此之后,docker将连接到守护进程并工作,无需sudo,不需要重新启动。

https://github.com/docker-archive/docker-snap/issues/1#issuecomment-423778054

执行如下命令:

docker context use default

我还遇到了“无法连接到Docker守护进程”的问题。这台主机上是否运行docker守护进程?”

我忘了用sudo。希望它能帮助到我们中的一些人。

$:docker images
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

$:sudo docker images
REPOSITORY   TAG   IMAGE ID   CREATED   SIZE

我也有类似的问题。我不得不注销并再次登录到shell,因为我刚刚安装了Docker,下面的命令在我的环境中没有显示。

export DOCKER_HOST=127.0.0.1:4243 >> ~/.bashrc