2

I am trying to host a simple static site using the Docker Nginx Image from Dockerhub: https://registry.hub.docker.com/_/nginx/

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   

3 Answers 3

3

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.

Sign up to request clarification or add additional context in comments.

Comments

1

Here is the way to connect nginx docker container service:

docker ps            # confirm nginx is running, which you have done.
docker port wargames-front-end  # get the ports, for example: 80/tcp, 0.0.0.0:8080->8080/tcp, 443/tcp
boot2docker ip       # get the IP address, for example: 192.168.59.103

So now, you should be fine to connect to:

http://192.168.59.103:8080
https://192.168.59.103:8080

1 Comment

I got a connection refused: pastebin.com/6hiAGeYm Someone mentioned forwarding ports in virtualbox?
1

Here's how I got it to work.

docker kill wargames-front-end
docker rm wargames-front-end
docker run --name wargames-front-end -d -p 8080:80 wargames-front-end

Then I went to my virtualbox and setup these settings:

enter image description here

2 Comments

In your example you are forwarding 8080:80 and in the virtual-box you are forwarding 8001. Just a note :)
I actually changed it for my example because I decided with a different port. But that wasn't the problem!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.