docker inspect Explained

What docker inspect does, with an example.

Published November 9, 2026

docker inspect returns detailed low-level information about containers, images, networks and volumes as JSON.

How it works

Use it to find IP addresses, mounts, environment variables, health status and exit codes. Format with Go templates or pipe to jq.

It is the first step when something behaves unexpectedly.

Try it

docker inspect -f '{{.NetworkSettings.IPAddress}}' web
172.17.0.2
docker inspect web | jq '.[0].State'

Practical examples

Container IP

docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' web

Environment variables

docker inspect -f '{{.Config.Env}}' web

Exit code

docker inspect -f '{{.State.ExitCode}}' web

Image layers

docker inspect nginx | jq '.[0].RootFS.Layers | length'

Common mistakes

  • Reading raw JSON instead of filtering.
  • Exposing secrets from env output in logs.
  • Mixing up object types (container vs image).

Key takeaways

  • docker inspect returns detailed low-level information about containers, images, networks and volumes as JSON.
  • Run docker <command> --help for all options.
  • Clean up unused resources regularly.

FAQ

Why is the IP empty?

With custom networks, read it from .NetworkSettings.Networks.

Where can I see all options?

Run the command with --help.

More General articles