abiosoft/colima · warning

error decoding docker response

Error message

error decoding docker response

What it means

The stdout of `<runtime> inspect` is decoded with encoding/json into a []struct{Mounts []{Source string}}. If the buffer is not valid JSON — the runtime printed warnings/errors to stdout, output was empty or truncated — decode fails and 'error decoding docker response' is returned. Note the underlying json error is discarded (no %w), so errors.Unwrap/Is cannot reach the cause; it surfaces only through the poll goroutine's log.

Source

Thrown at daemon/process/inotify/volumes.go:119

	log.Tracef("found containers %+v", containers)

	// fetch volumes
	var resp []struct {
		Mounts []struct {
			Source string `json:"Source"`
		} `json:"Mounts"`
	}
	{
		args := append([]string{}, cmdArgs...)
		args = append(args, "inspect")
		args = append(args, containers...)

		var buf bytes.Buffer
		if err := f.guest.RunWith(nil, &buf, args...); err != nil {
			return nil, fmt.Errorf("error inspecting containers: %w", err)
		}
		if err := json.NewDecoder(&buf).Decode(&resp); err != nil {
			return nil, fmt.Errorf("error decoding docker response")
		}
	}

	// process and discard redundant volumes
	vols := []string{}
	{
		shouldMount := func(child string) bool {
			// ignore all invalid directories.
			// i.e. directories not within the mounted VM directories
			for _, parent := range f.vmVols {
				if strings.HasPrefix(child, parent) {
					return true
				}
			}
			return false
		}

		for _, r := range resp {

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. run inspect manually in the guest and look for non-JSON lines before the array: `colima ssh -- docker ps -q | xargs docker inspect | head`
  2. disable/reconfigure any guest docker plugin that writes to stdout
  3. update colima — newer code wraps the decode cause, making diagnosis direct

Example fix

// before (daemon/process/inotify/volumes.go)
return nil, fmt.Errorf("error decoding docker response")

// after — preserve the cause for diagnosis
return nil, fmt.Errorf("error decoding docker response: %w", err)
Defensive patterns

Strategy: try-catch

Validate before calling

// validate payload shape before/while decoding
raw := buf.Bytes()
if len(bytes.TrimSpace(raw)) == 0 {
    return nil, nil // nothing running: no mounts
}
if !bytes.HasPrefix(bytes.TrimSpace(raw), []byte("[")) {
    return nil, fmt.Errorf("unexpected non-JSON inspect output: %.80s", raw)
}

Try / catch

if err := json.NewDecoder(&buf).Decode(&resp); err != nil {
    return nil, fmt.Errorf("error decoding docker response: %w", err) // keep the cause!
}

Prevention

When it happens

Trigger: runtime emitting non-JSON preamble lines on stdout (proxy notices, plugin warnings, 'permission denied' text); empty stdout on a zero-container edge path; output truncation with very many containers.

Common situations: docker CLI plugins or custom builds in the guest writing to stdout; older colima versions with this exact unwrapped message.

Related errors


AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15). Data as JSON: /api/errors/a224f836ee8c8da1. Report an issue: GitHub.