James001
James001

Reputation: 127

How to run a pod each node in Docker Swarm?

I want to run an application on docker swarm, but a pod should run on each node. Because it has a lot of port forwarding. I couldn't find any information about this. How can I limit a pod on each node? Especially, I can configure easily in Kubernetes.

Upvotes: 1

Views: 486

Answers (1)

Chris Becke
Chris Becke

Reputation: 36131

In docker swarm we would deploy a stack containing services.

Defined in yaml, the deploy mode lets us specify that an instance (a task) of the service needs to be created on each node:

version: "3.9"

services:
  example:
    image: nginx
    deploy:
      mode: global

docker stack deploy --compose-file stack.yml test-stack
docker service ps test-stack_example

will show that docker has deployed 1 service task to each node of the swarm.

Upvotes: 2

Related Questions