docker/cli · error
cannot supply extra formatting options to the pretty…
Error message
cannot supply extra formatting options to the pretty template
What it means
Identical logic to error 100 but for `docker service inspect`. After resolving the effective format string `f` (from `--format`, or from the Docker config file's `ServiceInspectFormat`, or defaulting to "raw"), this error fires at service/inspect.go:87-88 if `f` starts with "pretty" but is not exactly "pretty". Unlike the secret command, the format can also originate from the config file (`dockerCLI.ConfigFile().ServiceInspectFormat`), so a corrupted config value can trigger this without any `--format` flag on the command line.
Solutions
- Use exactly `--format pretty` or a full Go template (no "pretty" prefix)
- Check and fix the Docker config file (`~/.docker/config.json`) — look for a malformed `serviceInspectFormat` key and remove or correct it
- Use `--pretty` instead of `--format pretty` to bypass the format-string logic entirely
Example fix
# before (command-line)
docker service inspect --format "pretty {{.ID}}" myservice
# after
docker service inspect --pretty myservice
# --- config file fix ---
# before (~/.docker/config.json):
# { "serviceInspectFormat": "pretty extra" }
# after:
# { "serviceInspectFormat": "" } Defensive patterns
Strategy: validation
Validate before calling
// Validate effective format including config file fallback
func validateServiceFormat(format, configFormat string) error {
f := format
if len(f) == 0 {
f = configFormat
}
if strings.HasPrefix(f, "pretty") && f != "pretty" {
return fmt.Errorf("format %q is invalid: use 'pretty' exactly or a full Go template", f)
}
return nil
} Prevention
- Check ~/.docker/config.json for a malformed serviceInspectFormat value when debugging unexpected format errors
- Use --pretty instead of --format pretty to avoid the format-string validation entirely
- In automation, always pass --format explicitly (even if just 'json') to override any config file default
When it happens
Trigger: Passing `--format "pretty extra"` on the command line; or having `ServiceInspectFormat` set to a value like `"pretty foo"` in the Docker config file (`~/.docker/config.json`) while not passing `--format` on the CLI (lines 78-83 show the config file value is used as fallback).
Common situations: A Docker config file was manually edited or corrupted with a malformed `ServiceInspectFormat` value. Or a user tries to extend the pretty template with additional fields.
Related errors
- cannot supply extra formatting options to the pretty…
- --format is incompatible with human friendly format
- tty service logs only supported with --raw
- placement preference must be of the format
- invalid credential spec: value must be prefixed with…
AI-assisted analysis of docker/cli@4f84911bfe (2026-08-07).
Data as JSON: /api/errors/f3035d87c04e6848.
Report an issue: GitHub.
Appendix: source
Thrown at cli/command/service/inspect.go:88
res, err := apiClient.NetworkInspect(ctx, ref, client.NetworkInspectOptions{Scope: "swarm"})
if err == nil || !errdefs.IsNotFound(err) {
return res.Network, res.Raw, err
}
return nil, nil, fmt.Errorf("no such network: %s", ref)
}
f := opts.format
if len(f) == 0 {
f = "raw"
if len(dockerCLI.ConfigFile().ServiceInspectFormat) > 0 {
f = dockerCLI.ConfigFile().ServiceInspectFormat
}
}
// check if the user is trying to apply a template to the pretty format, which
// is not supported
if strings.HasPrefix(f, "pretty") && f != "pretty" {
return errors.New("cannot supply extra formatting options to the pretty template")
}
serviceCtx := formatter.Context{
Output: dockerCLI.Out(),
Format: newFormat(f),
}
if err := inspectFormatWrite(serviceCtx, opts.refs, getRef, getNetwork); err != nil {
return cli.StatusError{StatusCode: 1, Status: err.Error()}
}
return nil
}
View on GitHub (pinned to 4f84911bfe)