docker/cli ยท error

unsupported placement preference %s (only spread is supporte

Error message

unsupported placement preference %s (only spread is supported)

What it means

Error "unsupported placement preference %s (only spread is supported)" thrown in docker/cli.

Source

Thrown at cli/command/service/opts.go:104

}

func (o *placementPrefOpts) String() string {
	if len(o.strings) == 0 {
		return ""
	}
	return fmt.Sprintf("%v", o.strings)
}

// Set validates the input value and adds it to the internal slices.
// Note: in the future strategies other than "spread", may be supported,
// as well as additional comma-separated options.
func (o *placementPrefOpts) Set(value string) error {
	strategy, arg, ok := strings.Cut(value, "=")
	if !ok || strategy == "" {
		return errors.New(`placement preference must be of the format "<strategy>=<arg>"`)
	}
	if strategy != "spread" {
		return fmt.Errorf("unsupported placement preference %s (only spread is supported)", strategy)
	}

	o.prefs = append(o.prefs, swarm.PlacementPreference{
		Spread: &swarm.SpreadOver{
			SpreadDescriptor: arg,
		},
	})
	o.strings = append(o.strings, value)
	return nil
}

// Type returns a string name for this Option type
func (*placementPrefOpts) Type() string {
	return "pref"
}

// ShlexOpt is a flag Value which parses a string as a list of shell words
type ShlexOpt []string

View on GitHub (pinned to e9452d6e78)

When it happens

Trigger: Thrown at cli/command/service/opts.go:104 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of docker/cli@e9452d6e78 (2026-08-01). Data as JSON: /data/errors/b09e708f3e540178.json. Report an issue: GitHub.