{"record":{"id":"b21261ab50f5ecec","repo":"abiosoft/colima","slug":"failed-to-get-container-ip-w","errorCode":null,"errorMessage":"failed to get container IP: %w","messagePattern":"failed to get container IP: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"model/docker.go","lineNumber":286,"sourceCode":"\t\t// Check if container exists\n\t\tif err := guest.RunQuiet(\"docker\", \"inspect\", \"docker-model-runner\"); err == nil {\n\t\t\treturn nil\n\t\t}\n\n\t\tlog.Infof(\"docker-model-runner not found, starting it (attempt %d/3)...\", attempt)\n\t\t_ = guest.Run(\"docker\", \"model\", \"start-runner\")\n\t\ttime.Sleep(2 * time.Second)\n\t}\n\n\treturn fmt.Errorf(\"could not start docker-model-runner after 3 attempts\")\n}\n\n// getDockerModelRunnerIP returns the IP address of the docker-model-runner container.\nfunc getDockerModelRunnerIP(guest environment.VM) (string, error) {\n\toutput, err := guest.RunOutput(\"docker\", \"inspect\", \"docker-model-runner\",\n\t\t\"--format\", \"{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}\")\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get container IP: %w\", err)\n\t}\n\n\tip := strings.TrimSpace(output)\n\tif ip == \"\" {\n\t\treturn \"\", fmt.Errorf(\"container IP is empty\")\n\t}\n\n\treturn ip, nil\n}\n\n// startSocat starts socat in the background to forward a port to the container.\nfunc startSocat(guest environment.VM, port int, containerIP string) error {\n\tcmd := fmt.Sprintf(\"nohup socat TCP-LISTEN:%d,fork,reuseaddr TCP:%s:%d > /dev/null 2>&1 &\",\n\t\tport, containerIP, port)\n\treturn guest.Run(\"sh\", \"-c\", cmd)\n}\n\n// stopSocat stops the socat process for a given port.","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/model/docker.go#L268-L304","documentation":"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.","triggerScenarios":"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.","commonSituations":"First serve on a fresh VM where start-runner silently failed; manual cleanup of containers; runner name changed in a newer Docker version.","solutions":["Check the container exists: colima ssh -- docker ps -a | grep model-runner","Start it: colima ssh -- docker model start-runner (or retry serve, which runs ensureDockerModelRunner first)","If the name changed in a newer Docker, update colima so it queries the current container name","Verify docker engine health in the VM (docker info)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Confirm the container exists before relying on its IP.\nfunc runnerExists(guest environment.VM) bool {\n    return guest.RunQuiet(\"docker\", \"inspect\", \"docker-model-runner\") == nil\n}","typeGuard":null,"tryCatchPattern":"output, err := guest.RunOutput(\"docker\", \"inspect\", \"docker-model-runner\", \"--format\", tpl)\nif err != nil {\n    return \"\", fmt.Errorf(\"failed to get container IP: %w — runner container missing? start it with 'docker model start-runner'\", err)\n}","preventionTips":["Let ensureDockerModelRunner precede any docker-model-runner inspect","Avoid manually removing the runner container between ensure and serve steps","After Docker upgrades, confirm the runner container name hasn't changed"],"tags":["docker","inspect","networking","model-runner"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}