{"record":{"id":"e931723e38758c51","repo":"bcicen/ctop","slug":"cannot-inspect-container-v","errorCode":null,"errorMessage":"cannot inspect container: %v","messagePattern":"cannot inspect container: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"connector/manager/docker.go","lineNumber":108,"sourceCode":"\t\tTty:          true,\n\t})\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn dc.client.StartExec(execCmd.ID, api.StartExecOptions{\n\t\tInputStream:  &noClosableReader{os.Stdin},\n\t\tOutputStream: &frameWriter{os.Stdout, os.Stderr, os.Stdin},\n\t\tErrorStream:  os.Stderr,\n\t\tRawTerminal:  true,\n\t})\n}\n\nfunc (dc *Docker) Start() error {\n\tc, err := dc.client.InspectContainer(dc.id)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot inspect container: %v\", err)\n\t}\n\n\tif err := dc.client.StartContainer(c.ID, c.HostConfig); err != nil {\n\t\treturn fmt.Errorf(\"cannot start container: %v\", err)\n\t}\n\treturn nil\n}\n\nfunc (dc *Docker) Stop() error {\n\tif err := dc.client.StopContainer(dc.id, 3); err != nil {\n\t\treturn fmt.Errorf(\"cannot stop container: %v\", err)\n\t}\n\treturn nil\n}\n\nfunc (dc *Docker) Remove() error {\n\tif err := dc.client.RemoveContainer(api.RemoveContainerOptions{ID: dc.id}); err != nil {\n\t\treturn fmt.Errorf(\"cannot remove container: %v\", err)","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/bcicen/ctop/blob/59f00dd6aaebf48f3bc501e174f75f815c2619f0/connector/manager/docker.go#L90-L126","documentation":"Docker.Start inspects the container by ID before starting it. If InspectContainer fails (container doesn't exist, Docker daemon unreachable, API error), Start aborts with 'cannot inspect container: <cause>'.","triggerScenarios":"Calling Docker.Start() with an id referencing a removed/nonexistent container, or when the Docker daemon/remote API is unreachable or returns an error.","commonSituations":"Container was removed between creation and start; DOCKER_HOST misconfigured or daemon down; stale container id cached after a restart; insufficient permissions on the Docker socket.","solutions":["Verify the container exists (docker inspect <id>) and recreate it if removed","Check Docker daemon reachability and DOCKER_HOST configuration","Check permissions on /var/run/docker.sock or remote TLS settings","Refresh the stored container id after daemon/host restarts"],"exampleFix":"// before\ndc := &manager.Docker{ID: staleID}\ndc.Start() // cannot inspect container: No such container\n// after\nc, err := dc.Inspect(); if err != nil { c, err = dc.Create() }\nerr = dc.Start()","handlingStrategy":"try-catch","validationCode":"if _, err := dc.client.InspectContainer(dc.id); err != nil { /* recreate container before Start */ }","typeGuard":"func containerExists(dc *manager.Docker) bool { _, err := dc.client.InspectContainer(dc.id); return err == nil }","tryCatchPattern":"if err := dc.Start(); err != nil {\n    if strings.HasPrefix(err.Error(), \"cannot inspect container\") {\n        // recreate container or check daemon connectivity\n    }\n}","preventionTips":["Verify container existence before Start after daemon/host restarts","Monitor Docker daemon availability and DOCKER_HOST config","Check docker.sock permissions for the running user"],"tags":["docker","container","api"],"backgroundTag":"container-inspect-failed","analyzedSha":"59f00dd6aaebf48f3bc501e174f75f815c2619f0","analyzedAt":"2026-09-02T23:34:03.832Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}