泊坞窗:无法连接到泊坞窗守护程序

Mag*_*ick 5 ubuntu docker docker-compose

我正在安装以下docker软件运行Ubuntu:

$ docker version
Client:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   a34a1d5
 Built:        Fri Nov 20 17:56:04 UTC 2015
 OS/Arch:      linux/amd64
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

$ docker-compose -v
docker-compose version 1.7.0, build 0d7bf73
Run Code Online (Sandbox Code Playgroud)

尝试运行docker-compose时出现以下错误:

$ sudo docker-compose up
ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
Run Code Online (Sandbox Code Playgroud)

我尝试了以下方法:

systemctl unmask docker.service
systemctl unmask docker.socket
systemctl start docker.service

sudo service docker status
? docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2016-04-29 13:36:57 CEST; 4min 3s ago
     Docs: https://docs.docker.com
 Main PID: 6394 (docker)
   Memory: 13.3M
      CPU: 119ms
   CGroup: /system.slice/docker.service
           ??6394 /usr/bin/docker daemon -H fd://

Apr 29 13:36:57 Charles docker[6394]: time="2016-04-29T13:36:57.722083467+02:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon opt...d IP address"
Apr 29 13:36:57 Charles docker[6394]: time="2016-04-29T13:36:57.805189862+02:00" level=warning msg="Your kernel does not support swap memory limit."
Apr 29 13:36:57 Charles docker[6394]: time="2016-04-29T13:36:57.827955299+02:00" level=info msg="Loading containers: start."
Apr 29 13:36:57 Charles docker[6394]: time="2016-04-29T13:36:57.828083895+02:00" level=info msg="Loading containers: done."
Apr 29 13:36:57 Charles docker[6394]: time="2016-04-29T13:36:57.828095512+02:00" level=info msg="Daemon has completed initialization"
Apr 29 13:36:57 Charles docker[6394]: time="2016-04-29T13:36:57.828125198+02:00" level=info msg="Docker daemon" commit=a34a1d5 execdriver=native-0.2 graphdriver=aufs version=1.9.1
Apr 29 13:36:57 Charles systemd[1]: Started Docker Application Container Engine.
Apr 29 13:37:10 Charles systemd[1]: Started Docker Application Container Engine.
Apr 29 13:37:34 Charles systemd[1]: Started Docker Application Container Engine.
Apr 29 13:38:01 Charles systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.
anton@Charles:~/Documents/software/deliverable$ docker ps
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
Run Code Online (Sandbox Code Playgroud)

须藤吗

当我使用sudo docker运行时,似乎正在运行:

$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
$ docker ps
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?

Moe*_*ald 1

看看这个线程。它似乎处理同样的问题。

回答:

Docker 机器正在运行。但是你需要导出一些环境才能连接到 Docker 机器。默认情况下,docker CLI 客户端尝试使用 http+unix://var/run/docker.sock 与守护进程进行通信(如错误消息所示)。

使用 eval $(docker-machine env dev) 导出正确的环境变量,然后重试。您还可以运行 docker-machine env dev 来查看它将导出的环境变量。请注意,其中之一是 DOCKER_HOST,正如错误消息表明您可能需要设置一样。