Docker tasks are performed only by workers.

Let's say that we are working in swarm mode, and we have three nodes:

  • Manager1
  • worker1
  • worker2

Is it possible to create a service and indicate that tasks should be performed only for workers (worker1 and worker2), and not for managers (manager1)

To create a service, the following command is executed:

docker-machine ssh manager1 "docker service create --network dognet --name dog-db redis"

and when I use the service:

docker-machine ssh manager1 "docker service ps dog-db"

I get:

ID                         NAME      IMAGE  NODE      DESIRED STATE  CURRENT STATE            ERROR
3kvfpbhl6fj0qwtglc5k7sbkw  dog-db.1  redis  manager1  Running        Preparing 4 seconds ago  
+4
source share
2 answers

While you can use constraints (c --constraint node.role=worker) to exclude a subset of nodes based on their role (manager or worker), I would go as far as disconnecting Manager (s) from the action, as worker (s) , with:

# Disables the Manager as a Worker node

docker node update --availability drain manager1

, (CPU, RAM, fds), , , , , . , ( ).

(, , , ), , .

:

: Docker Swarm Swarm.

+6

, node. :

docker service create --network dognet --constraint node.role==worker --name dog-db redis

+4

Source: https://habr.com/ru/post/1661892/


All Articles