I have a cluster of 10 Swarm nodes started via docker swarm join
command
If i want to scale a docker instance to 15 via
docker service create --replicas 15
how does docker swarm know where to start the container?
is it round-robin or does it take into consideration of compute resource (how much cpu/mem being used)?
When you create a service or scale it in the Swarm mode, scheduler
on Elected Leader
(one of the managers) will choose a node to run the service on. There are 3 strategies currently available to the leader.
The spread
and binpack
strategies compute rank according to a node’s available CPU, its RAM, and the number of containers it has. The random
strategy uses no computation. It selects a node at random and is primarily intended for debugging.
Under the spread
strategy, Swarm optimizes for the node with the least number of containers. The binpack
strategy causes Swarm to optimize for the node which is most packed.
Swarm uses spread by default.
Keep in mind you can Constraint
Containers on specific nodes too.
It's not possible to set strategies in docker version 1.12.1 (Latest release to posting date)