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

我怎么解决这个问题?


当前回答

检查你是否正在使用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/

其他回答

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

sudo usermod -aG docker $USER

然后注销并重新登录。

LINUX

你可以用这个答案https://stackoverflow.com/a/33596140/13997503 即使在使用这个之后,仍然会得到相同的错误。然后你可能已经安装了docker桌面,现在切换到docker引擎

可以使用此命令删除docker桌面服务文件

$ rm -rf ~/.docker

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

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

# 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

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