If there is a web app running in my cluster, how do I access it from an external client? Do I need a reverse proxy or is there a "swarm way" of doing this?


When you create your service you need to use the --publish option.


docker service create --detach=true --replicas 3 --publish 80:80 --name httpd httpd

Now port 80 is exposed to the main network. Usefully, every server in the swarm publishes port 80 and will do an internal redirect to wherever the container is actually running.

Similarly, if you use a stack then you use the ports option. E.g.:

    image: httpd
      - 80:80

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.