Docker Community Forums

Share and learn in the Docker community.

How to expose individual machines on a port

docker
swarm

(Justin Heyes-Jones) #1

I’m trying to figure out a nice way to access a particular port on a number of containers running in the cluster. Specifically they are Akka containers opening port 19999 for a management service.

My problem is that a management tool will be outside of the swarm and I would like it to be able to dynamically add each container that is listening on that port as they come and go during the applications lifetime.

One solution I’ve thought of is to expose the port but not specify the destination so they all get assigned ports. Then use docker service ls against the master to find any containers listening on 19999 and find out which port they are mapped to externally.

Is there a more usual way to achieve this kind of result?