docker/cli ยท error
invalid restart policy format: no policy provided before col
Error message
invalid restart policy format: no policy provided before colon
What it means
Error "invalid restart policy format: no policy provided before colon" thrown in docker/cli.
Source
Thrown at opts/parse.go:89
}
// ParseRestartPolicy parses a restart policy string ("name[:max-retries]")
// into a [container.RestartPolicy].
//
// Parsing is syntactic only; semantic validation is deferred to the daemon/API.
// An empty input returns a zero-value policy for backward compatibility. The
// retry count, if set, must be an integer (negative values are allowed here
// but may be rejected by the daemon).
func ParseRestartPolicy(policy string) (container.RestartPolicy, error) {
if policy == "" {
// For backward compatibility, do not set an explicit default ("no"),
// as older daemons may not support it.
return container.RestartPolicy{}, nil
}
name, count, ok := strings.Cut(policy, ":")
if ok && name == "" {
return container.RestartPolicy{}, errors.New("invalid restart policy format: no policy provided before colon")
}
var retryCount int
if count != "" {
c, err := strconv.Atoi(count)
if err != nil {
return container.RestartPolicy{}, errors.New("invalid restart policy format: maximum retry count must be an integer")
}
retryCount = c
}
return container.RestartPolicy{
Name: container.RestartPolicyMode(name),
MaximumRetryCount: retryCount,
}, nil
}
View on GitHub (pinned to e9452d6e78)
When it happens
Trigger: Thrown at opts/parse.go:89 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/761ed6d410949821.json.
Report an issue: GitHub.