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

runInspect for `docker config inspect` (cli/command/config/inspect.go:46) special-cases the 'pretty' format. If opts.format begins with the literal "pretty" but is not exactly "pretty" (e.g. 'pretty {{.x}}'), it returns errors.New("cannot supply extra formatting options to the pretty template") at line 61. The pretty formatter is fixed and does not accept Go template directives.

Solutions

  1. Use --pretty alone for the human-friendly view, OR use --format with a pure Go template (without the 'pretty' prefix) for custom output.
  2. If you want templated fields, drop 'pretty': `docker config inspect -f '{{.ID}} {{.Spec.Name}}' NAME`.
  3. Do not combine --pretty with a custom --format string.

Example fix

# before
docker config inspect -f 'pretty {{.ID}}' mycfg
# after — either use pretty alone, or a real template
docker config inspect --pretty mycfg
# or
docker config inspect -f '{{.ID}} {{.Spec.Name}}' mycfg
Defensive patterns

Strategy: validation

Validate before calling

// Normalize the format before runInspect:
if strings.HasPrefix(format, "pretty") && format != "pretty" {
    // either strip to "pretty" or reject with guidance
    return errors.New("'pretty' cannot be combined with template directives")
}

Try / catch

if err := runInspect(ctx, cli, opts); err != nil {
    if strings.Contains(err.Error(), "cannot supply extra formatting options to the pretty template") {
        // tell user to use --pretty alone or a plain template
    }
    return err
}

Prevention

When it happens

Trigger: Running `docker config inspect --pretty --format 'pretty {{.ID}}' NAME` or `docker config inspect -f 'pretty-extra' NAME`. The --pretty flag sets format to exactly "pretty"; the error arises only when the user manually supplies a --format string that starts with 'pretty' but continues with template text.

Common situations: Users assuming 'pretty' is a template prefix to which they can append fields; typos like 'pretty{{.ID}}'; copy-pasting a format from another inspect command.

Related errors


AI-assisted analysis of docker/cli@4f84911bfe (2026-08-07). Data as JSON: /api/errors/832b27018c5fb41f. Report an issue: GitHub.

Appendix: source

Thrown at cli/command/config/inspect.go:61

}

// runInspect inspects the given Swarm config.
func runInspect(ctx context.Context, dockerCLI command.Cli, opts inspectOptions) error {
	apiClient := dockerCLI.Client()

	if opts.pretty {
		opts.format = "pretty"
	}

	getRef := func(id string) (any, []byte, error) {
		res, err := apiClient.ConfigInspect(ctx, id, client.ConfigInspectOptions{})
		return res.Config, 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")
	}

	configCtx := formatter.Context{
		Output: dockerCLI.Out(),
		Format: newFormat(opts.format, false),
	}

	if err := inspectFormatWrite(configCtx, opts.names, getRef); err != nil {
		return cli.StatusError{StatusCode: 1, Status: err.Error()}
	}
	return nil
}

View on GitHub (pinned to 4f84911bfe)