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

我怎么解决这个问题?


当前回答

如果你在OS X上运行Docker,运行下面的eval对我来说是有效的。

eval "$(docker-machine env default)"

如果你不想在每个终端会话上都运行这个eval语句,你可以在bash_profile中添加:

#Docker
eval "$(docker-machine env default)"

确保重新启动终端会话或在bash_profile上运行source以使更改生效。

其他回答

这种情况通常不会发生。但是有一天,消息出现了(如下所示),一个简单的重启修复了它

unix:///var/run/ Docker .sock无法连接到Docker守护进程。docker守护进程正在运行吗?

当Docker与snap一起安装时,我有时会在重新启动我的机器时遇到OP错误。在我的情况下,运行sudo snap logs docker在日志中显示了一个错误:

启动守护进程时发现pid文件错误,确认docker未运行或删除/var/snap/docker/423/run/docker.pid

执行sudo命令后,rm /var/snap/docker/423/run/docker. sh。我可以正常启动Docker。

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

ls -l /var/run/docker.sock

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

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

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

为了解决这个问题,我必须启用docker服务:

sudo systemctl enable /usr/lib/systemd/system/docker.service

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.