Docker Swarm - container schedule on each machine

I am currently trying to instantiate a Redis container separately on each cluster machine using Docker Swarm / Compose. I am currently using 4 cars. Using binding labels, the idea was to make sure that two instances of redis would not be assigned to the same computer.

At first it worked.

redis:
  image: redis
  environment:
    AFFINITY: com.myself.name!=redis
  labels:
    - "com.myself.name=redis"

However, after some containers stopped simulating failures, pushing them back, disconnecting all containers, and then finally everyone starts from the very beginning with help docker-compose scale redis=4, I find redis, I launch two containers on the same machine, although there are 4 available in the cluster.

What exactly am I doing wrong? Thanks.

+4
2

:

redis:
  image: redis
  environment:
    - "affinity:container!=*redis*"
  labels:
    - "com.myself.name=redis"

!

,

+4

docker

redis:
  image: redis
  environment:
    - affinity:com.myself.name!=redis
  labels:
    - "com.myself.name=redis"
0

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


All Articles