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?
1 Answer
When you create your service you need to use the --publish
option.
E.g.:
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.:
services:
web:
image: httpd
ports:
- 80:80