Reputation: 3904
Hi have docker swarm running currently on 3 nodes as managers. I have a simple service replicated 6 times spread evenly across all 3 nodes. However when I take 1 or 2 of the nodes offline then all the services spread between the remaining node/nodes. When I bring all the nodes back online all of the services remain on the node/nodes that were not taken offline. I know this is by design as the concept is you can't take services offline for the sake of re-balancing. However to run this in production I would need to have at least 1 service running on a node at all times.
Is there anyway to auto-balance to ensure at least one service is running on every Docker Swarm node?
Upvotes: 1
Views: 1459
Reputation: 39277
This wont work for multiple replicas per node. But incase you are not aware of global services:
Swarm mode has two types of services, replicated
and global
. For replicated
services, you specify the number of replica tasks for the swarm manager to schedule onto available nodes. For global
services, the scheduler places one task on each available node.
docker service create \
--name <service name> \
--mode global \
<image name:tag>
Please note --mode global
.
The replicated
mode is the default.
I know this is by design as the concept is you can't take services offline for the sake of re-balancing
You can scale down and scale up again to rebalance the containers across the nodes without downtime, because one container will be available at all times.
Upvotes: 1