Docker Community Forums

Share and learn in the Docker community.

Can you publish a docker service container port to host?

(Louis Burton) #1

If a container was created via a docker service (i.e. a replica), can I publish the container port to the host in the same way you would a normal container? I believe the answer may be no, and so if not, is there a reason not to support this?

I would like to use a docker service to scale and manage my service (in a cluster), but I would like each container to still be directly externally accessible without use of the routing mesh. This is useful in examples where I communicate with a service that supports smart routing, such as a data grid (i.e. hazelcast, ignite, etc.).
To go direct to the correct container rather than hitting a VIP, bouncing to a container which potentially is not the correct partition for a specific entry, and then needing to make another hop.

If I am misusing this, or my intentions are flawed, I’d appreciate any corrections! To me though, it seems useful to have a docker service container that is externally accessible.