docker/cli ยท error

failed to execute template: %w

Error message

failed to execute template: %w

What it means

Error "failed to execute template: %w" thrown in docker/cli.

Source

Thrown at cli/command/container/list.go:95

	}

	if options.nLatest && options.last == -1 {
		listOptions.Limit = 1
	}

	// always validate template when `--format` is used, for consistency
	if len(options.format) > 0 {
		tmpl, err := templates.Parse(options.format)
		if err != nil {
			return client.ContainerListOptions{}, fmt.Errorf("failed to parse template: %w", err)
		}

		optionsProcessor := formatter.NewContainerContext()

		// This shouldn't error out but swallowing the error makes it harder
		// to track down if preProcessor issues come up.
		if err := tmpl.Execute(io.Discard, optionsProcessor); err != nil {
			return client.ContainerListOptions{}, fmt.Errorf("failed to execute template: %w", err)
		}

		// if `size` was not explicitly set to false (with `--size=false`)
		// and `--quiet` is not set, request size if the template requires it
		if !options.quiet && !listOptions.Size && !options.sizeChanged {
			// The --size option isn't set, but .Size may be used in the template.
			// Parse and execute the given template to detect if the .Size field is
			// used. If it is, then automatically enable the --size option. See #24696
			//
			// Only requesting container size information when needed is an optimization,
			// because calculating the size is a costly operation.

			if _, ok := optionsProcessor.FieldsUsed["Size"]; ok {
				listOptions.Size = true
			}
		}
	}

View on GitHub (pinned to e9452d6e78)

When it happens

Trigger: Thrown at cli/command/container/list.go:95 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/d4524fd8a98dc334.json. Report an issue: GitHub.