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

我怎么解决这个问题?


当前回答

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.

其他回答

Linux

Linux安装后步骤文档揭示了以下步骤:

创建docker组。 Sudo groupadd docker 将用户添加到docker组。 sudo usermod -aG docker $(whoami) 退出并重新登录以确保docker以正确的权限运行。 码头工人开始。 Sudo服务docker启动

Mac OS X

正如Dayel Ostraco所说,有必要添加环境变量:

docker-machine start # Start virtual machine for docker
docker-machine env  # It's helps to get environment variables
eval "$(docker-machine env default)" # Set environment variables

docker-machine start命令输出注释来指导这个过程。

要修复此问题,您需要在终端中发出以下命令。我将解释每一步:

# Uninstall Docker from apt packages
$ sudo apt-get remove docker docker.io

# Remove it from the libraries just to be
# sure it's gone forever
$ sudo rm -rf /var/lib/docker/*

现在,如果你想简化事情并获得更多时间,你可以使用参数installDocker运行我的init脚本:

# Pull the init script from GitHub
$ wget https://github.com/dminca/dotfiles/blob/master/init

# Add rights to run the script
$ chmod 755 init

# Just run the script with the installDocker parameter
$ ./init installDocker

重新启动是可选的,但我建议您这样做,以确保一切正常运行。

执行ps aux | grep docker查看守护进程是否正在运行。如果没有,执行/etc/init.d /码头工人开始

我知道这篇文章里已经有很多答案了。只是我想补充一个简单的答案,解决上述问题。

sudo systemctl start docker

运行上面的命令,它将启动所有与docker相关的线程/服务。

我也遇到了同样的问题——“无法连接到docker守护进程。”(除了我在试图启动服务器时没有得到任何“文件未找到”错误。)

“ps”表示“/usr/bin/docker -d”仍在运行

我意识到我自己从来没有成功地运行过服务器。每一次尝试都产生了结果

...
2014/03/24 21:57:29 pid file found, ensure docker is not running or delete /var/run/docker.pid

所以我后来才意识到,安装docker可能已经注册了upstart守护进程,upstart已经为我启动了它。因此,试图杀死守护进程以手动重新启动它会失败(不允许操作)。所以我做了一个

sudo kill -9 <PID>

守护进程。另一个守护进程立即取代了它的位置,这个新的守护进程现在让我的CLI客户端连接:

$ sudo docker info
Containers: 0
Images: 0
Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Dirs: 0
WARNING: No memory limit support
WARNING: No swap limit support