docker/cli ยท error

template parsing error: %w

Error message

template parsing error: %w

What it means

Error "template parsing error: %w" thrown in docker/cli.

Source

Thrown at cli/command/formatter/formatter.go:88

// Context contains information required by the formatter to print the output as desired.
type Context struct {
	// Output is the output stream to which the formatted string is written.
	Output io.Writer
	// Format is used to choose raw, table or custom format for the output.
	Format Format
	// Trunc when set to true will truncate the output of certain fields such as Container ID.
	Trunc bool

	// internal element
	header any
	buffer *bytes.Buffer
}

func (c *Context) parseFormat() (*template.Template, error) {
	tmpl, err := templates.Parse(c.Format.templateString())
	if err != nil {
		return nil, fmt.Errorf("template parsing error: %w", err)
	}
	return tmpl, nil
}

func (c *Context) postFormat(tmpl *template.Template, subContext SubContext) {
	out := c.Output
	if out == nil {
		out = io.Discard
	}
	if !c.Format.IsTable() {
		_, _ = c.buffer.WriteTo(out)
		return
	}

	// Write column-headers and rows to the tab-writer buffer, then flush the output.
	tw := tabwriter.NewWriter(out, 10, 1, 3, ' ', 0)
	_ = tmpl.Funcs(templates.HeaderFunctions).Execute(tw, subContext.FullHeader())
	_, _ = tw.Write([]byte{'\n'})

View on GitHub (pinned to e9452d6e78)

When it happens

Trigger: Thrown at cli/command/formatter/formatter.go:88 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/9210167808a36c5e.json. Report an issue: GitHub.