Access to Docker Container Port

2019-09-08 15:40发布

问题:

Im running boot2docker. I have a container running which Ive opened port 8000 for. i.e

docker@boot2docker:/home/djangoapp/testtools$ docker ps -a
CONTAINER ID        IMAGE                                                              COMMAND                CREATED             STATUS                    PORTS                      NAMES
4c52d46227f2        felix001/djangoapp:1.0                                             "/bin/bash"            22 hours ago        Up 22 hours               127.0.0.1:8000->8000/tcp   ecstatic_noyce

However if I try to access the port I get a RST,

docker@boot2docker:/home/djangoapp/testtools$ curl http://127.0.0.1:8000
curl: (56) Recv failure: Connection reset by peer

Any ideas ?

回答1:

You need to use the IP address of the boot2docker VM. Usually 192.168.59.103.



回答2:

Have you tried seeing if the server is running? First, you are going to need to root into the container:

docker exec -it 4c52d46227f2 bash

Then, check if the server is running:

python manage.py runserver 0.0.0.0:8000

And, it might be something else other than manage.py for your container, but you get the idea.

Here is another article to help out to understand the manual process and setup: https://ochronus.com/docker-primer-django/



标签: docker