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

  1. Use --pretty alone for human-readable output, with no --format flag.
  2. Use a fully custom --format Go template without the 'pretty' prefix.
  3. 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

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


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)