Home > Software design >  docker swarm nodes prefer to use own container first before going to use other node's container
docker swarm nodes prefer to use own container first before going to use other node's container

Time:01-26

i have 3 swarm managers node without any worker node in global mode this makes each node have exactly one container.

when i send request to any node, that request may be processed by any of the container but i want to create priority that it should preferably be executed by the container of that node which i send request. and if the container connot respond, it should use the container of the other nodes.

i use chatgpt to get my answer and it says you can use --placement-pref but its not working.

CodePudding user response:

Docker Swarms mesh networking is very simple and does a simple round robin load balancing.

If this is not wanted you can either use host mode networking, or for service to service calls you could use tasks.<service> to get the DNSRR record, or a different mesh implementation like Hashicorp Consul. (Not that Hashicorp Consul necessarily implements your use case).

  • Related