docker/cli · error
error: no such object
Error message
error: no such object: %s
What it means
Produced by 'docker inspect' when a given reference is not found in any searched object type. The elementSearcher iterates over all applicable types and, finding no match (and skipping not-found when type is unconstrained), returns this 'no such object' error.
Solutions
- Verify the object exists with the relevant 'docker <type> ls' (e.g. 'docker ps -a', 'docker images').
- Confirm you're on the right context/daemon ('docker context ls').
- Drop --type if set, in case the object is a different kind than assumed.
- Use the full ID instead of an ambiguous short prefix.
Example fix
# before docker inspect mycontainer # after: confirm it exists, then inspect docker ps -a --filter name=mycontainer docker inspect mycontainer # use exact name/id
Defensive patterns
Strategy: try-catch
Validate before calling
// Confirm object existence before inspect (example: container)
if _, err := apiClient.ContainerInspect(ctx, ref, client.ContainerInspectOptions{}); err != nil {
if errdefs.IsNotFound(err) {
return fmt.Errorf("no such object: %s", ref)
}
return err
} Type guard
func isNoSuchObjectErr(err error) bool {
return err != nil && strings.Contains(err.Error(), "no such object:")
} Try / catch
v, raw, err := elementSearcher(ref)
if err != nil {
if isNoSuchObjectErr(err) {
// optionally search a broader type set or report gracefully
return nil
}
return err
} Prevention
- Verify the object with the relevant 'docker <type> ls' first.
- Use the right context/daemon.
- Pass full IDs to avoid ambiguous prefixes.
When it happens
Trigger: Running 'docker inspect <missing-id>' where the ID/name doesn't match any container, image, network, volume, service, task, node, secret, plugin, or config. Triggered at inspect.go:281 after the loop exhausts types.
Common situations: Typo in the ID/name; object was deleted; wrong context/daemon (object exists on a different host); abbreviated ID prefix is ambiguous and matched nothing; type filter hides the actual object type.
Related errors
- context does not exist
- type is empty: must be one of
- unknown type: : must be one of
- no signer for repository
- error reading from STDIN: data is empty
AI-assisted analysis of docker/cli@4f84911bfe (2026-08-07).
Data as JSON: /api/errors/a13f7edfa5fd11d5.
Report an issue: GitHub.
Appendix: source
Thrown at cli/command/system/inspect.go:281
}
}
if isSwarmSupported == swarmUnsupported {
continue
}
}
v, raw, err := inspectData.objectInspector(ref)
if err != nil {
if typeConstraint == "" && isErrSkippable(err) {
continue
}
return v, raw, err
}
if getSize && !inspectData.isSizeSupported {
_, _ = fmt.Fprintln(dockerCLI.Err(), "WARNING: --size ignored for", inspectData.objectType)
}
return v, raw, err
}
return nil, nil, fmt.Errorf("error: no such object: %s", ref)
}
}
func isErrSkippable(err error) bool {
return errdefs.IsNotFound(err) ||
strings.Contains(err.Error(), "not supported") ||
strings.Contains(err.Error(), "invalid reference format")
}
View on GitHub (pinned to 4f84911bfe)