无法从 docker-compose 连接到 docker [英] Can't connect to docker from docker-compose
问题描述
我在 Mac OS 10.8.5 上安装了 docker-machine 0.1.0 和 docker-compose 1.1.0.
Docker-machine 运行正常,可以通过 docker-machine ssh 连接.
$ docker-machine ls名称活动驱动程序状态 URL SWARMdev * virtualbox 运行 tcp://192.168.99.100:2376
但是无法从 docker-compose 连接.
$ docker-compose up
<块引用>
无法连接到 http+unix://var/run/docker.sock 上的 Docker 守护进程 - 它正在运行吗?
如果它位于非标准位置,请使用 DOCKER_HOST 环境变量指定 URL.
我的 Dockerfile 和 docker-compose.yml 在这里.
Dockerfile
FROM centos:centos7DOCKER_HOST tcp://192.168.99.100:2376
docker-compose.yml
网站:建造: .
为什么无法连接?有什么想法吗?
Docker 机器正在运行.但是需要导出一些环境才能连接到Docker机器.默认情况下,docker
CLI 客户端尝试使用 http+unix://var/run/docker.sock
与守护进程通信(如错误消息所示).
使用 eval $(docker-machine env dev)
导出正确的环境变量,然后重试.您也可以运行 docker-machine env dev
来查看它将导出的环境变量.请注意,其中之一是 DOCKER_HOST
,正如错误消息表明您可能需要设置.
I installed docker-machine 0.1.0 and docker-compose 1.1.0 on Mac OS 10.8.5.
Docker-machine is running normally and able to connect by docker-machine ssh.
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM
dev * virtualbox Running tcp://192.168.99.100:2376
However can't connect from docker-compose.
$ docker-compose up
Couldn't connect to Docker daemon at http+unix://var/run/docker.sock - is it running?
If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
My Dockerfile and docker-compose.yml is here.
Dockerfile
FROM centos:centos7
DOCKER_HOST tcp://192.168.99.100:2376
docker-compose.yml
web:
build: .
Why can't connect? Any ideas?
The Docker machine is running. But you need to export some environment to connect to the Docker machine. By default, the docker
CLI client is trying to communicate to the daemon using http+unix://var/run/docker.sock
(as shown in the error message).
Export the correct environment variables using eval $(docker-machine env dev)
and then try again. You can also just run docker-machine env dev
to see the environment variables it will export. Notice that one of them is DOCKER_HOST
, just as the error message suggests you may need to set.
这篇关于无法从 docker-compose 连接到 docker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!