docker-machine:无法从主机访问容器的Web服务器 [英] docker-machine: Can't access container's web server from host

查看:120
本文介绍了docker-machine:无法从主机访问容器的Web服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚使用自制软件在Mac上使用Docker-Toolbox安装了Docker:使用自制软件安装Docker



在使用Rails,Postgres创建并配置容器并启动docker-组成一切看起来不错,但我无法从主机访问Web服务器。





<$ p $的输出p> $ docker-compose up

dummy_1 |我[2016-03-30T14:55:53.130639#6] INFO-:正在监听addr = 0.0.0.0:8000 fd = 10

当我在Google Chrome浏览器中键入网址时, http://0.0.0.0:8000/ 我得到

 无法访问此网站

0.0.0.0拒绝连接。
ERR_CONNECTION_REFUSED

所以我尝试了

  $ docker-machine env dummy 

具有以下输出:

  export DOCKER_TLS_VERIFY = 1 
export DOCKER_HOST = tcp://192.168.99.100:2376
export DOCKER_CERT_PATH = / Users / choi / .docker / machine / machines / dummy
export DOCKER_MACHINE_NAME = dummy

当我在Chrome http://192.168.99.100:2376 中尝试时,我得到了一个空白文件。为什么会这样呢?我希望我的Rails应用程序具有默认的问候页面。

解决方案

192.168.99.100 是您的Docker主机的IP。您需要暴露容器的端口,然后才能从外部连接到它。



我对Docker Compose并不熟悉,但是您发布的建议端口日志已公开。因此,请尝试 http://192.168.99.100:8000



(原因 http://192.168.99.100:2376 不起作用是因为这是Docker守护程序本身的地址和端口,它不是基于HTTP的。对于 0.0.0.0 :这是您的Web服务器在容器内部 上侦听的地址,等同于其中的所有外部连接。但是,没有任何端口暴露,这是没有办法的内!)


I just installed Docker with Docker-Toolbox on my Mac using homebrew: install docker with homebrew

After creating and configuring a Container with Rails, Postgres and starting docker-compose up everything looks fine but i can't access the webserver from host.

The output of

$ docker-compose up

dummy_1    | I, [2016-03-30T14:55:53.130639 #6]  INFO -- : listening on addr=0.0.0.0:8000 fd=10

When i type in Google Chrome the url http://0.0.0.0:8000/ i get

This site can’t be reached

0.0.0.0 refused to connect.
ERR_CONNECTION_REFUSED

So i tried

$ docker-machine env dummy

with the following output:

export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/Users/choi/.docker/machine/machines/dummy"
export DOCKER_MACHINE_NAME="dummy"

When i try in Chrome http://192.168.99.100:2376 i get a blank file downloaded. Why is it so? I expect the default greeting page of my Rails App.

解决方案

192.168.99.100 is the IP of your Docker host, in this instance. You need to expose the port of your container and then you will be able to connect to it from the outside world.

I'm not familiar with Docker Compose, but the log you have posted suggests port 8000 is exposed. Try, therefore, http://192.168.99.100:8000.

(The reason http://192.168.99.100:2376 doesn't work is because that's the address and port of the Docker daemon itself, which isn't HTTP-based. As for 0.0.0.0: This is the address which your web server is listening on inside the container and equates to all external connections therein. However, without any ports exposed, there's no way in!)

这篇关于docker-machine:无法从主机访问容器的Web服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆