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.
We can get the address of a linked container using envoronment variables in the standard way eg
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.
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