abiosoft/colima · error

failed to get container IP: %w

Error message

failed to get container IP: %w

What it means

getDockerModelRunnerIP runs docker inspect docker-model-runner --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' in the VM; a non-zero exit wraps into this error. The inspect call failed: the container does not exist (by that name), docker CLI/engine problems, or the runner was never started.

Source

Thrown at model/docker.go:286

		// Check if container exists
		if err := guest.RunQuiet("docker", "inspect", "docker-model-runner"); err == nil {
			return nil
		}

		log.Infof("docker-model-runner not found, starting it (attempt %d/3)...", attempt)
		_ = guest.Run("docker", "model", "start-runner")
		time.Sleep(2 * time.Second)
	}

	return fmt.Errorf("could not start docker-model-runner after 3 attempts")
}

// getDockerModelRunnerIP returns the IP address of the docker-model-runner container.
func getDockerModelRunnerIP(guest environment.VM) (string, error) {
	output, err := guest.RunOutput("docker", "inspect", "docker-model-runner",
		"--format", "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}")
	if err != nil {
		return "", fmt.Errorf("failed to get container IP: %w", err)
	}

	ip := strings.TrimSpace(output)
	if ip == "" {
		return "", fmt.Errorf("container IP is empty")
	}

	return ip, nil
}

// startSocat starts socat in the background to forward a port to the container.
func startSocat(guest environment.VM, port int, containerIP string) error {
	cmd := fmt.Sprintf("nohup socat TCP-LISTEN:%d,fork,reuseaddr TCP:%s:%d > /dev/null 2>&1 &",
		port, containerIP, port)
	return guest.Run("sh", "-c", cmd)
}

// stopSocat stops the socat process for a given port.

View on GitHub (pinned to c3a5f9184d)

Solutions

  1. Check the container exists: colima ssh -- docker ps -a | grep model-runner
  2. Start it: colima ssh -- docker model start-runner (or retry serve, which runs ensureDockerModelRunner first)
  3. If the name changed in a newer Docker, update colima so it queries the current container name
  4. Verify docker engine health in the VM (docker info)
Defensive patterns

Strategy: try-catch

Validate before calling

// Confirm the container exists before relying on its IP.
func runnerExists(guest environment.VM) bool {
    return guest.RunQuiet("docker", "inspect", "docker-model-runner") == nil
}

Try / catch

output, err := guest.RunOutput("docker", "inspect", "docker-model-runner", "--format", tpl)
if err != nil {
    return "", fmt.Errorf("failed to get container IP: %w — runner container missing? start it with 'docker model start-runner'", err)
}

Prevention

When it happens

Trigger: Serving before the runner container was created (ensureDockerModelRunner could also be bypassed); container removed by docker model rm/reinstall between checks; docker daemon unreachable in the VM.

Common situations: First serve on a fresh VM where start-runner silently failed; manual cleanup of containers; runner name changed in a newer Docker version.

Related errors


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