How do I configure docker compose to expose ports correctly?

With boot2docker (on Mac or Windows), to access any port from localhost, you have to configure your VirtualBox VM in order to port-forward that port from the VM into the host.

Your port mappings are correct, but you still need to make visible to your host (Mac) the one port you want to access from localhost (your Mac).

See for instance “Using boot2docker to run Docker on a Mac or Windows” from Andrew Odewahn:

enter image description here

That way, you don’t have to find out what the IP of your machine is.
(Which you can see with docker-machine ls followed by docker-machine ip <name>)

Leave a Comment