无法连接到Docker Nginx版本 [英] Unable to connect to Docker Nginx build
问题描述
我正在尝试使用Dockerhub的Docker Nginx映像来托管一个简单的静态网站: https: //registry.hub.docker.com/_/nginx/
I am trying to host a simple static site using the Docker Nginx Image from Dockerhub: https://registry.hub.docker.com/_/nginx/
有关我的设置的注释,我在OSX上使用boot2docker。
A note on my setup, I am using boot2docker on OSX.
我按照说明操作,即使我无法连接到正在运行的容器:
I have followed the instructions and even I cannot connect to the running container:
MacBook-Pro:LifeIT-war-games-frontend ryan$ docker build -t wargames-front-end .
Sending build context to Docker daemon 813.6 kB
Sending build context to Docker daemon
Step 0 : FROM nginx
---> 42a3cf88f3f0
Step 1 : COPY app /usr/share/nginx/html
---> Using cache
---> 61402e6eb300
Successfully built 61402e6eb300
MacBook-Pro:LifeIT-war-games-frontend ryan$ docker run --name wargames-front-end -d -p 8080:8080 wargames-front-end
9f7daa48a25bdc09e4398fed5d846dd0eb4ee234bcfe89744268bee3e5706e54
MacBook-Pro:LifeIT-war-games-frontend ryan$ curl localhost:8080
curl: (52) Empty reply from server
MacBook-Pro:LifeIT-war-games-frontend ryan$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9f7daa48a25b wargames-front-end:latest "nginx -g 'daemon of 3 minutes ago Up 3 minutes 80/tcp, 0.0.0.0:8080->8080/tcp, 443/tcp wargames-front-end
推荐答案
而不是localhost,请使用boot2docker ip。首先执行 boot2docker ip
并使用该ip:
<你的-b2d-ip>:8080
还需要确保你将您的端口8080转发到VirtualBox for boot2docker。
Instead of localhost, use boot2docker ip. First do boot2docker ip
and use that ip:
<your-b2d-ip>:8080
. Also you need to make sure you forwarded your port 8080 in VirtualBox for boot2docker.
这篇关于无法连接到Docker Nginx版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!