当我把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

我怎么解决这个问题?


当前回答

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

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

其他回答

尝试将当前用户添加到docker组:

sudo usermod -aG docker $USER

然后注销并重新登录。

找出Docker不能工作的原因的最好方法是手动运行守护进程。

$ sudo service docker stop
$ ps aux | grep docker  # do this until you don't see /usr/bin/docker -d
$ /usr/bin/docker -d

Docker守护进程记录到STDOUT,因此它将开始输出它正在做的任何事情。

这就是我的问题所在:

[8bf47e42.initserver()] Creating pidfile
2015/01/11 15:20:33 pid file found, ensure docker is not running or delete /var/run/docker.pid

这是因为实例是从另一个虚拟机克隆的。我只需要删除pidfile,之后一切都正常了。

当然,我并不是盲目地假设这样可以工作,而是建议再次手动运行守护进程,并在启动服务备份之前检查日志输出是否有其他错误。

I also had the same issue. The problem was in sockets allocated to docker-daemon and docker-client. First, permission was not set for the docker-client on docker.sock You can set it using "sudo usermod -aG docker $USER" Then check your bash file where the docker-client is running, For me it was on 0.0.0.0:2375, while docker-daemon was running on unix socket.(It was set in the configuration file of dockerd). Just comment the bash-line and it'll work fine. But if you want to make it work on TCP port instead of unix socket, change the configuration file of dockerd and set it on 0.0.0.0.2375 and keep the line in bash as it is if present or set it to 0.0.0.0:2375.

已经有很多答案了,但希望这能帮助到一些人。这是通过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

在Mac OS-X上,这可能只是意味着docker安装已经过时或无法运行。只需从官方网站下载最新的docker并安装即可。

为我工作。