Search code examples
dockerboot2docker

Ports not accessible in Docker on Mac


NOTE: I'm a networking noob, so please explain answers accordingly.

I am running boot2docker+VirtualBox on Mac OS.

Launch my Docker container like this:

docker run -it -p 80:80 -p 28017:28017 mine/envbox bash

In the container I start nginx and mongo. Then inside the container I try:

curl localhost:80  // returns content
curl localhost:28017 // returns content

So I know my services are up and healthy inside the container. Outside the container on my host I run:

curl http://$(boot2docker ip):80  // returns content
curl http://$(boot2docker ip):28017  // connection error

I've configured port forwarding on my VirtualBox on my Mac like this: (port 28017 should be exposed)

enter image description here

Why can't I see port 28017 on my host?


Solution

  • Got it. mongodb (the process binding to port 28017) has a config that blocks non-local access by default, so naturally it wouldn't be visible outside the container. Un-commenting that config resolved the issue.

    At least it forced me to upgrade from boot2docker to docker toolbox, so that's a good thing.