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
Thrown by runInspect when the resolved --format string starts with the prefix 'pretty' but is not exactly equal to 'pretty'. This prevents combining the built-in human-friendly pretty template with custom Go template directives, which is unsupported. Note that passing --pretty sets the format to exactly 'pretty'.
Solutions
- Use --pretty alone for human-readable output, with no --format flag.
- Use a fully custom --format Go template without the 'pretty' prefix.
- Remove any leading 'pretty' token from your --format string.
Example fix
# before
docker node inspect --format 'pretty {{.ID}}' self
# after
docker node inspect --pretty self
# or
docker node inspect --format '{{.ID}}' self Defensive patterns
Strategy: validation
Validate before calling
// Disallow mixing 'pretty' with extra template text before running inspect
if strings.HasPrefix(format, "pretty") && format != "pretty" {
return fmt.Errorf("use --pretty alone or a custom --format without the 'pretty' prefix")
} Prevention
- Never combine --pretty with a custom --format string.
- If you need specific fields, write a full Go template without the 'pretty' token.
- Treat 'pretty' as a reserved mode, not a composable prefix.
When it happens
Trigger: Running 'docker node inspect' with a format string like '--format "pretty {{.ID}}"', or supplying both --pretty and a custom --format (line 64: HasPrefix(format,'pretty') && format != 'pretty').
Common situations: Trying to add fields to the pretty output; combining --pretty with --format; copy-pasting a template that begins with the word 'pretty'.
Related errors
- node ID not found in /info
- every ip-range or gateway must have a corresponding subnet
- multiple overlapping subnet configuration is not supported
- network prune has been cancelled
- context must be a directory
AI-assisted analysis of docker/cli@4f84911bfe (2026-08-07).
Data as JSON: /api/errors/7bb4174e5bcb3e89.
Report an issue: GitHub.
Appendix: source
Thrown at cli/command/node/inspect.go:65
apiClient := dockerCLI.Client()
if opts.pretty {
opts.format = "pretty"
}
getRef := func(ref string) (any, []byte, error) {
nodeRef, err := Reference(ctx, apiClient, ref)
if err != nil {
return nil, nil, err
}
res, err := apiClient.NodeInspect(ctx, nodeRef, client.NodeInspectOptions{})
return res.Node, res.Raw, err
}
// check if the user is trying to apply a template to the pretty format, which
// is not supported
if strings.HasPrefix(opts.format, "pretty") && opts.format != "pretty" {
return errors.New("cannot supply extra formatting options to the pretty template")
}
nodeCtx := formatter.Context{
Output: dockerCLI.Out(),
Format: newFormat(opts.format, false),
}
if err := inspectFormatWrite(nodeCtx, opts.nodeIds, getRef); err != nil {
return cli.StatusError{StatusCode: 1, Status: err.Error()}
}
return nil
}
View on GitHub (pinned to 4f84911bfe)