This is a creation in Article, where the information may have evolved or changed.
Docker Swarm manage
The commands scheduler
are built with filter and strategy ( cli/manage.go
):
sched := scheduler.New(s, fs)
scheduler
the actual function is to select cluster.ContainerConfig
a list that meets the requirements node
( Docker Engine
):
// SelectNodesForContainer will return a list of nodes where the container can// be scheduled, sorted by order or preference.func (s *Scheduler) SelectNodesForContainer(nodes []*node.Node, config *cluster.ContainerConfig) ([]*node.Node, error) { candidates, err := s.selectNodesForContainer(nodes, config, true) if err != nil { candidates, err = s.selectNodesForContainer(nodes, config, false) } return candidates, err}func (s *Scheduler) selectNodesForContainer(nodes []*node.Node, config *cluster.ContainerConfig, soft bool) ([]*node.Node, error) { accepted, err := filter.ApplyFilters(s.filters, config, nodes, soft) if err != nil { return nil, err } if len(accepted) == 0 { return nil, errNoNodeAvailable } return s.strategy.RankAndSort(config, accepted)}