Federico Bellini
Federico Bellini

Reputation: 504

Expose ports on a Docker Swarm

Is it possible to "expose" ports in a docker Swarm?

Something similar to the expose instruction in the docker-compose, which differently from "ports" does not expose the ports externally to the network.

If it's not possible, why?

Upvotes: 0

Views: 1548

Answers (2)

Federico Bellini
Federico Bellini

Reputation: 504

I noticed that it does the same as expose if you specify target and published with the same port

docker service create --publish target=8080,published=8080 ...

Upvotes: 0

BMitch
BMitch

Reputation: 263587

Expose is documentation. Any two containers can communicate between each other on ports the containers are using as long as they share a docker network. This is the same whether it's a bridge or overlay network (assuming the host is correctly configured to support overlay networks).

Upvotes: 2

Related Questions