Contents

Docker inspect Tutorial: View Detailed Container and Image Information with -f Format Examples

docker inspect displays the full configuration and state of Docker objects in JSON format. Objects can include containers, images, volumes, and networks.

Syntax

docker inspect [OPTIONS] NAME OR ID [NAME OR ID...]
OptionDescription
-f, --format TEMPLATEUse a Go template to retrieve only the parts you need, or json
--type TYPESpecify the object type: container, image, volume, network, and so on (use this when names overlap)
-s, --sizeFor containers: also display the size

Full output

$ docker inspect web | head -n 12
[
    {
        "Id": "1ec4fdc5c592b09b64e8f28869c37f89ab17163f88bfcb09e82815a44b0e1164",
        "Created": "2026-10-13T05:28:35.05807319Z",
        "Path": "/docker-entrypoint.sh",
        "Args": [
            "nginx",
            "-g",
            "daemon off;"
        ],
        "State": {
            "Status": "running",

The full output contains hundreds of lines. In practice, you almost always add -f to retrieve only the fields you need.

-f templates: common queries

The following queries are for a container named web that was started with -e APP_MODE=demo:

$ docker inspect -f "{{.State.Status}} {{.State.StartedAt}}" web
running 2026-10-13T05:28:40.584115149Z

$ docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" web
172.18.0.2

$ docker inspect -f "{{json .Config.Env}}" web
["APP_MODE=demo","PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","NGINX_VERSION=1.30.5","PKG_RELEASE=1","DYNPKG_RELEASE=1","NJS_VERSION=1.0.1","NJS_RELEASE=1","ACME_VERSION=0.4.1"]

$ docker inspect -f "{{.Config.Image}} {{.HostConfig.RestartPolicy.Name}}" web
nginx:1.30-alpine no
What you want to knowTemplate
Status and start time{{.State.Status}} {{.State.StartedAt}}
Exit code and whether it ran out of memory{{.State.ExitCode}} {{.State.OOMKilled}}
IP address{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}
Environment variables{{json .Config.Env}}
Image in use and restart policy{{.Config.Image}} {{.HostConfig.RestartPolicy.Name}}
Mounts{{json .Mounts}}
Port mappings{{json .NetworkSettings.Ports}}
Health check results{{json .State.Health}}
PID on the host{{.State.Pid}}

Template syntax:

  • {{.FIELD.SUBFIELD}}: retrieve a value.
  • {{json .FIELD}}: output an entire section as JSON (an array or object).
  • {{range .LIST}}...{{end}}: iterate over each item in a list or object.

Docker 29 change: The {{.NetworkSettings.IPAddress}} field found in older tutorials has been removed. Running it produces template parsing error: ... map has no entry for key "IPAddress". Use the range syntax in the table above instead.

Images, volumes, and networks

$ docker inspect -f "{{.Config.Cmd}} {{.Config.Entrypoint}}" nginx:1.30-alpine
[nginx -g daemon off;] [/docker-entrypoint.sh]

$ docker inspect -f "{{.Architecture}} {{.Os}} {{.Size}}" nginx:1.30-alpine
amd64 linux 92750711

$ docker volume create v1
v1

$ docker inspect -f "{{.Mountpoint}}" v1
/var/lib/docker/volumes/v1/_data

$ docker inspect --type network -f "{{range .IPAM.Config}}{{.Subnet}}{{end}}" bridge
172.18.0.0/16

$ docker volume rm v1
v1
  • For an image, .Config.Cmd and .Config.Entrypoint are the default startup command, .Architecture is the CPU architecture, and .Size is in bytes (92750711 is about 92.8 MB).
  • A volume's .Mountpoint is the actual location of its data on the Docker host. In Docker Desktop, this path is inside the virtual machine and cannot be opened directly on Windows or macOS.
  • --type network specifies that you are querying a network, and .IPAM.Config contains the subnet configuration.

Exercises

Exercise: Find out which paths are mounted in the web container and how its ports are mapped.

Answer
docker inspect -f "{{json .Mounts}}" web
docker inspect -f "{{json .NetworkSettings.Ports}}" web

The web container on this page has no mounts and was not started with -p, so the results are [] and {"80/tcp":null}, which lists only the container port.

FAQ

Why does the {{.NetworkSettings.IPAddress}} I found online fail?

Docker 29 no longer provides this field, so using it produces the error map has no entry for key "IPAddress". Get the IP address from each network: {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}.

How can I find out which fields I can query?

Run the command once without -f; the JSON structure in the output gives you the field names. For example, State.Status is written as {{.State.Status}}. You can also print an entire section with {{json .Config}}.

How do I quote -f on Windows?

In both PowerShell and CMD, wrap the template in double quotes, for example, docker inspect -f "{{.State.Status}}" web. The template itself cannot contain double quotes; use a single-quoted string when needed.

Updated October 14, 2026