This is a creation in Article, where the information may have evolved or changed.
Docker Swarmschedulerwill choose to meet the requirements node to create container :
candidates, err := s.selectNodesForContainer(nodes, config, true)
nodeDefined in scheduler/node/node.go :
// Node is an abstract type used by the scheduler.type Node struct { ID string IP string Addr string Name string Labels map[string]string Containers cluster.Containers Images []*cluster.Image UsedMemory int64 UsedCpus int64 TotalMemory int64 TotalCpus int64 HealthIndicator int64}
Cluster.listNodesThe method is implemented as follows:
// listNodes returns all validated engines in the cluster, excluding pendingEngines.func (c *Cluster) listNodes() []*node.Node { c.RLock() defer c.RUnlock() out := make([]*node.Node, 0, len(c.engines)) for _, e := range c.engines { node := node.NewNode(e) for _, pc := range c.pendingContainers { if pc.Engine.ID == e.ID && node.Container(pc.Config.SwarmID()) == nil { node.AddContainer(pc.ToContainer()) } } out = append(out, node) } return out}
is actually from the Cluster.engines build node list (because it's still in a Cluster.pendingEngines pending state). The following scheduler will node select the appropriate one from this list node .