{"record":{"id":"faf23d1d85787147","repo":"pranshuparmar/witr","slug":"no-container-found-matching-q","errorCode":null,"errorMessage":"no container found matching %q","messagePattern":"no container found matching %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/app/app.go","lineNumber":755,"sourceCode":"\t\treturn ExitNotFound\n\tcase strings.Contains(msg, \"invalid\") ||\n\t\tstrings.Contains(msg, \"must specify\"):\n\t\treturn ExitInvalidInput\n\tdefault:\n\t\treturn ExitInternalError\n\t}\n}\n\n// processContainerTarget handles `-c/--container` lookups. Resolves against\n// every available container runtime, dispatches to the normal pipeline if\n// the container's main process is host-visible, otherwise renders the\n// runtime-side metadata via the container fallback view.\nfunc processContainerTarget(cmd *cobra.Command, outw io.Writer, outp output.Printer, t model.Target, flags appFlags, multiMode bool, jsonResults *[]string) int {\n\tcolorEnabled := useColor(flags, outw)\n\n\tmatches := procpkg.ResolveContainer(t.Value, flags.exact)\n\tif len(matches) == 0 {\n\t\terr := fmt.Errorf(\"no container found matching %q\", t.Value)\n\t\treturn handleResolveError(cmd, outw, outp, t, err, flags, multiMode, jsonResults)\n\t}\n\n\tif len(matches) > 1 {\n\t\tif multiMode && flags.json {\n\t\t\t*jsonResults = append(*jsonResults, jsonErrorEntry(t, fmt.Sprintf(\"multiple containers matched (%d results)\", len(matches))))\n\t\t} else {\n\t\t\tprintContainerMultiMatch(outp, matches, colorEnabled)\n\t\t}\n\t\treturn ExitInvalidInput\n\t}\n\n\tmatch := matches[0]\n\tprocpkg.EnrichContainer(match)\n\tpid := procpkg.ResolveContainerHostPID(match.Runtime, match.ID)\n\tif pid > 0 && procpkg.PIDBelongsToContainer(pid, match.ID) {\n\t\tres, err := pipeline.AnalyzePID(pipeline.AnalyzeConfig{\n\t\t\tPID:     pid,","sourceCodeStart":737,"sourceCodeEnd":773,"githubUrl":"https://github.com/pranshuparmar/witr/blob/dc4fa1da82d3e266fcbd928641b4f30b3077c64f/internal/app/app.go#L737-L773","documentation":"processContainerTarget resolves the --container target via ResolveContainer (backed by container-runtime metadata). When no container matches the given value (name or id, honoring the exact flag), the library builds 'no container found matching %q' and delegates to handleResolveError for consistent reporting.","triggerScenarios":"Passing --container with a name/id that has no match: misspelled name, container already removed, only a partial id given with --exact, or the container belongs to a runtime the library's fallback view cannot see.","commonSituations":"Container restarted and got a new id/name; docker-compose project prefix changed; using a short container id with --exact; inspecting on a host where the container runtime socket is unavailable so metadata looks empty.","solutions":["List containers (`docker ps` / `ctr containers list`) and copy the exact name or full id.","Remove --exact or use a longer/more precise identifier if partial matching was intended.","Verify the container is running (not exited/removed) before inspecting.","Confirm the container runtime is reachable (socket permissions, DOCKER_HOST) so resolution can see containers."],"exampleFix":"// before\n$ errlookup --container web   // exact id needed after redeploy\n// after\n$ docker ps --format '{{.ID}} {{.Names}}'   # get exact name/id\n$ errlookup --container myproj-web-1","handlingStrategy":"validation","validationCode":"func containerExists(name string) bool {\n    out, err := exec.Command(\"docker\", \"ps\", \"--format\", \"{{.Names}}\").Output()\n    if err != nil { return false }\n    for _, n := range strings.Split(strings.TrimSpace(string(out)), \"\\n\") {\n        if n == name || strings.HasSuffix(n, name) { return true }\n    }\n    return false\n}\nif !containerExists(\"myproj-web-1\") {\n    return errors.New(\"container not running; check docker ps\")\n}","typeGuard":null,"tryCatchPattern":"err := runLookup(target)\nif err != nil && strings.Contains(err.Error(), \"no container found matching\") {\n    log.Printf(\"container %q not found; skipping\", target.Value)\n    return nil\n}\nif err != nil { return err }","preventionTips":["Copy container names/ids from `docker ps` output rather than typing them.","Remember containers get fresh ids/names on recreate; resolve at run time.","Verify the container runtime socket is reachable before inspecting.","Omit --exact when using partial container ids."],"tags":["containers","docker","not-found","cli"],"backgroundTag":"container-not-found","analyzedSha":"dc4fa1da82d3e266fcbd928641b4f30b3077c64f","analyzedAt":"2026-09-01T12:17:08.767Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}