4

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 1

3

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
1
  • How would that look like in a docker-compose file?
    – Soerendip
    Aug 12, 2021 at 4:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .