Reputation: 6290
This has to be a simple problem. I'm using boot2docker. If I ssh into boot2docker:
docker@boot2docker:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
89ec1492d7c7 mycontainer:latest "/bin/sh -c nginx" 35 seconds ago Up 35 seconds 80/tcp, 0.0.0.0:80->1000/tcp desperate_mestorf
Then curl:
docker@boot2docker:~$ curl localhost:1000 curl: (7) Failed connect to
localhost:1000; Connection refused
docker@boot2docker:~$ curl
localhost:80 curl: (56) Recv failure: Connection reset by peer
Curl'd on port 80 just to make sure I'm not going crazy. Then I connect to my containers bash:
docker@boot2docker:~$ docker exec -i -t 89ec1492d7c7 bash
root@89ec1492d7c7:/srv/www# curl localhost
<!DOCTYPE html><html><head><link rel="stylesheet" href="/main.css"></head><body><h1>Welcome to Harp.</h1><h3>This is yours to own. Enjoy.</h3></body></html>root
Boom! It works, even tried this while leaving the default port 80. What's really weird is I have other containers on my box that I can get to. Even outside of my boot2docker VM (which I'm only using to take one more thing out of the equation). This must be simple right?
Upvotes: 3
Views: 5289
Reputation: 45243
just another the same question in Unable to connect to Docker Nginx build
Here is the way to connect nginx docker container service:
docker ps # confirm nginx is running, which you have done.
docker port desperate_mestorf # get the ports, for example: 80/tcp, 0.0.0.0:80->1000/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:1000
Upvotes: 2