Multiple docker containers, IP addresses, VM, OSX

I am running docker on OSX via boot2docker. I am using docker remotely, via the API.

How can I map these different container IP addresses (from VM) to the same one in VM, but on different port? E.G.

<local.ip>:9001 ->
<local.ip>:9002 ->

where local.ip may be either ip from boot2docker or anything else.

Possible solution is to define port bindings when creating container and bind each container to a different port. However, I would like to avoid that, since this config becomes part of the container, and only exist because running on OSX. If I do all this above on linux, we would not have this issue.

How to map inner containers to different ports?

  • How to stop the client IP address getting lost in a Cloudflare/Docker/NGINX/LAMP site?
  • How does Docker bypass needing an OS?
  • Why Kafka broker connects to itself?
  • Redis: ERR Rewriting config file: Permission denied when using Docker data volume
  • How do pass in DOCKER_OPTS into docker image running from Docker for Mac?
  • Kafka and Docker: Pushing a Kafka Messages to the another's Dockerized Consumer
  • One Solution collect form web for “Multiple docker containers, IP addresses, VM, OSX”

    Publishing ports is the right solution. You have the same problem whether you’re running remotely or locally, just the IP address changes.

    For example, say I start the following web servers:

    $ docker run -d -p 8000:80 nginx
    $ docker run -d -p 8001:80 nginx

    From inside the VM (run boot2docker ssh), I can then run curl localhost:8000 or curl localhost:8001 to reach the website. This is the normal way of working with Docker on Linux. From the Mac command line, it becomes curl $(boot2docker ip):8000 because of the VM, but we’ve not done anything different with regards to starting the web servers because of boot2docker.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.