docker inspect Command Reference
Return low-level information on Docker objects as JSON.
docker inspect outputs the full JSON metadata for one or more containers, images, volumes, or networks. In CI it is used with --format to pull out a single field such as health status, exit code, or assigned IP for use in scripts.
Common flags
--format- Go template to extract a field, e.g. "{{.State.Health.Status}}"--type- restrict object type, e.g. container or image-s, --size- include container size (with --type container)
Example
shell
docker inspect --format '{{.State.Health.Status}}' app-db
docker inspect --format '{{.State.ExitCode}}' app-tests
docker inspect --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' app-webIn CI
Poll docker inspect --format {{.State.Health.Status}} until it reports healthy before running tests against a dependency. Read {{.State.ExitCode}} to fail a job on a non-zero container exit when the container itself does not propagate status.
Key takeaways
- --format extracts a single field instead of the full JSON blob.
- Health status and exit code are common fields to gate or fail CI steps.
- inspect works across containers, images, volumes, and networks.
Related guides
docker ps Command ReferenceReference for docker ps in CI: list running or all containers with -a, -q, --filter, and --format to inspect…
docker logs Command ReferenceReference for docker logs in CI: fetch container stdout and stderr with --tail, --since, --timestamps, and -f…
docker network create Command ReferenceReference for docker network create in CI: create a user-defined bridge network so containers can reach each…