pranshuparmar/witr · error
no container found matching %q
Error message
no container found matching %q
What it means
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.
Source
Thrown at internal/app/app.go:755
return ExitNotFound
case strings.Contains(msg, "invalid") ||
strings.Contains(msg, "must specify"):
return ExitInvalidInput
default:
return ExitInternalError
}
}
// processContainerTarget handles `-c/--container` lookups. Resolves against
// every available container runtime, dispatches to the normal pipeline if
// the container's main process is host-visible, otherwise renders the
// runtime-side metadata via the container fallback view.
func processContainerTarget(cmd *cobra.Command, outw io.Writer, outp output.Printer, t model.Target, flags appFlags, multiMode bool, jsonResults *[]string) int {
colorEnabled := useColor(flags, outw)
matches := procpkg.ResolveContainer(t.Value, flags.exact)
if len(matches) == 0 {
err := fmt.Errorf("no container found matching %q", t.Value)
return handleResolveError(cmd, outw, outp, t, err, flags, multiMode, jsonResults)
}
if len(matches) > 1 {
if multiMode && flags.json {
*jsonResults = append(*jsonResults, jsonErrorEntry(t, fmt.Sprintf("multiple containers matched (%d results)", len(matches))))
} else {
printContainerMultiMatch(outp, matches, colorEnabled)
}
return ExitInvalidInput
}
match := matches[0]
procpkg.EnrichContainer(match)
pid := procpkg.ResolveContainerHostPID(match.Runtime, match.ID)
if pid > 0 && procpkg.PIDBelongsToContainer(pid, match.ID) {
res, err := pipeline.AnalyzePID(pipeline.AnalyzeConfig{
PID: pid,View on GitHub (pinned to dc4fa1da82)
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.
Example fix
// before
$ errlookup --container web // exact id needed after redeploy
// after
$ docker ps --format '{{.ID}} {{.Names}}' # get exact name/id
$ errlookup --container myproj-web-1 Defensive patterns
Strategy: validation
Validate before calling
func containerExists(name string) bool {
out, err := exec.Command("docker", "ps", "--format", "{{.Names}}").Output()
if err != nil { return false }
for _, n := range strings.Split(strings.TrimSpace(string(out)), "\n") {
if n == name || strings.HasSuffix(n, name) { return true }
}
return false
}
if !containerExists("myproj-web-1") {
return errors.New("container not running; check docker ps")
} Try / catch
err := runLookup(target)
if err != nil && strings.Contains(err.Error(), "no container found matching") {
log.Printf("container %q not found; skipping", target.Value)
return nil
}
if err != nil { return err } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- no matching process found
- must specify --pid, --port, --file, --container, or a proces
- completed with exit code %d
- no process ancestry found
AI-assisted analysis of pranshuparmar/witr@dc4fa1da82 (2026-09-01).
Data as JSON: /api/errors/faf23d1d85787147.
Report an issue: GitHub.