1

I think I am missing something obvious but I can't seem to crack this one. I am trying to map a port from a django application running uwsgi in a docker container to my local Macintosh host. Here is the setup.

Mac 10.11 running docker-machine 0.5.1 with virtualbox 5.0.10 and docker 1.9.1

I created a server with docker-machine setup my docker file and successfully built my docker container. In the container I have the following command

# Port to expose
EXPOSE 8000

Which maps to the port used via uwsgi inside the container. When I runt he container via

eval "$(docker-machine env dev)"
docker-machine ip dev
192.168.99.100

docker run -P launch

The container starts properly. If I enter the container and perform a

curl http://localhost:8000

I get my HTML as I would expect. On the outside a docker inspect container_id gets me a

    "Ports": {
        "8000/tcp": [
            {
                "HostIp": "0.0.0.0",
                "HostPort": "32768"
            }
        ]
    },

So i can see the mapping to 32768 on the docker-machine host of 192.168.99.100 as from the above commands. However whenever I try and curl http://192.168.99.100:32768

curl http://192.168.99.100:32768
curl: (7) Failed to connect to 192.168.99.100 port 32768: Connection  refused 

So any thoughts on this?? Everything should work as I understand docker.

Thanks Craig

Craig
  • 141
  • 1
  • 1
  • 7
  • Can you post the `Dockerfile` or at the very least the configuration and command used to start the uwsgi server? This smells like uwsgi is only listening on 127.0.0.1... – Andy Shinn Dec 06 '15 at 22:42

1 Answers1

0

Since you are running through a VirtualBox VM, I would still recommend mapping the port on the VirtualBox level, as I mention in "How to connect mysql workbench to running mysql inside docker?"

VBoxManage controlvm "boot2docker-vm" --natpf1 "tcp-port8000 ,tcp,,8000,,8000"
VBoxManage controlvm "boot2docker-vm" --natpf1 "udp-port8000 ,udp,,8000,,8000"

And run the container with an explicit port mapping (instead of the random -P)

docker run -p 8000:8000 launch
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250