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 -> 172.17.0.61:8080
<local.ip>:9002 -> 172.17.0.62:8080

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?

  • docker private image can not be pulled in centos7
  • How compares Istio to Docker Swarm?
  • Dockers container source code mounting failed in Ubuntu
  • How to make `docker run` inherit ulimits
  • Docker on Windows Nano Server: There is not enough space on the disk
  • Load balance docker swarm
  • 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.