When publishing ports with docker run, we can have docker dynamically choose a host port from within a specified range
Here, docker has chosen a free port in the range 30005-30010 on the host to map to the container's port 80. It does not seem possible to do this with docker swarm services, either using the cli or compose files. e.g.
~ $ docker service create -p 30005-30010:80 alpine tail -f /dev/null
invalid argument "30005-30010:80" for p: invalid hostport binding (30005-30010) for port (80)
When publishing ports with docker run, we can have docker dynamically choose a host port from within a specified range
Here, docker has chosen a free port in the range 30005-30010 on the host to map to the container's port 80. It does not seem possible to do this with docker swarm services, either using the cli or compose files. e.g. ~ $ docker service create -p 30005-30010:80 alpine tail -f /dev/null invalid argument "30005-30010:80" for p: invalid hostport binding (30005-30010) for port (80)
Text took from: https://stackoverflow.com/questions/47792383/docker-swarm-published-port-range
I've create a new issue because the comment on the link above