I have a docker image that exposes a service at a given/static port, let’s say 80. I am starting multiple containers from this image w/o configuring specific port mappings. I basically want to let the docker infrastructure select, for each container, an available port on the host and map it to the container port 80. I basically end up with the following:
HOST_host:dynamic-port1 -> CONTAINER1_host:80 (Service-Instance1)
HOST_host:dynamic-port2 -> CONTAINER2_host:80 (Service-Instance2)
HOST_host:dynamic-port3 -> CONTAINER3_host:80 (Service-Instance3)
Now, each service instance, which runs in a docker container, needs to advertise its public address during the bootstrap of the container. So, Service-Instance1 advertises HOST_host:dynamic-port1, Service-Instance2 advertises HOST_host:dynamic-port2, and so on. How can each service instance get the host port mapping for “its” port 80?
Thanks in advance.