Providing a stable url to access a docker container from another docker container

We are using docker-compose to bring up multiple containers and link them together.

We need to be able to persist the url of a service running in containerA in our data store so that we can look it up at a later date and use it to access the service from containerB. containerB should not have to know whether the service is running as a local container or not, it should just be able to grab the url and use it.

  • How to run a command on a linked docker container?
  • Can't connect to container from docker host
  • Docker Remote Api from external machine doesn't respond
  • How do I set VirtualBox VM options using docker-machine?
  • after delete docker image, why can still find the deleted image by _catlog api?
  • Docker EXPOSE vs command line -p option (boot2docker)
  • We can get the address of a linked container using envoronment variables in the standard way eg

    http://$CONTAINER_A_SERVICE_PORT_9000_TCP_ADDR:$CONTAINER_A_SERVICE_PORT_9000_TCP_PORT/someresource

    but my understanding is that if we store this url and try to access the service after restarting the containers, docker may have assigned a new port and/or ip to the container and the address could be invlaid.

    At the moment all I can think of is exposing the port of the container on the host machine and using the public address of the host as the stable endpoint to the container but I would really like a solution that avoided going out to the public network.

    Any ideas would be greatly appreciated.

  • How to obtain container Ip from another container?
  • what are the different between LXD,LXC and User mode linux?
  • Docker daemon with --default-ulimit
  • Docker expose not working
  • Installed docker and ran a container with mongodb, now brew's mongodb isn't working
  • Mesosphere inter-service communication using Marathon
  • One Solution collect form web for “Providing a stable url to access a docker container from another docker container”

    I would use the hostname of serviceB that gets put into /etc/hosts

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