inspection
docker inspect
Returns low-level JSON metadata about Docker objects — containers, images, networks, volumes, and more. Supports Go template formatting for extracting specific fields.
docker inspect [OPTIONS] NAME|ID [NAME|ID...] Common flags
| Flag | Purpose |
|---|---|
| -f, --format | Format output with a Go template |
| --type | Restrict to a specific object type (container, image, network, etc.) |
| -s, --size | Include size information for containers |
Examples
docker inspect web Full JSON metadata for the container
docker inspect -f '{{.NetworkSettings.IPAddress}}' web Extract just the container IP
docker inspect --type image nginx:alpine Force lookup as an image when names collide
docker inspect -f '{{range .Mounts}}{{.Source}}->{{.Destination}}{{println}}{{end}}' db List mount sources and destinations
Gotcha
Container and image can share the same name — use --type to disambiguate. Field paths are case-sensitive and change between object types; check the JSON structure first before writing a template.
Related commands
docker ps
Lists containers along with their status, ports, and identifiers. By default it shows only running containers unless -a is passed.
docker images
Lists images stored in the local image store with their repository, tag, ID, and size. Alias for docker image ls.
docker network
Manages Docker networks — create, inspect, connect, disconnect, and remove user-defined bridges, overlays, or macvlan networks. Enables container-to-container DNS resolution by name.
docker volume
Manages persistent named volumes for containers — create, list, inspect, remove, and prune. Named volumes survive container removal and are the recommended storage mechanism over bind mounts for stateful data.
docker top
Displays the running processes inside a container, similar to running ps on the host restricted to that container's PID namespace. Accepts standard ps flags after the container name.
← All Docker commands · Docker vs Kubernetes · Docker vs VMs