Home / Alt manpages / docker-image-inspect(1)

  • docker-image-inspect(1)
  • User command
  • linux

Inspect Docker Image Metadata Without Guesswork

A bad deploy always raises one question: which image is actually running, and docker image inspect answers it. There is no need to guess. You will finish with a repeatable way to check which Docker image you have, identify its platform, and extract the few fields you actually need. The examples use Docker CLI 29.8.1 from package docker-ce-cli 5:29.8.1-1~ubuntu.24.04~noble, with the local alpine image. Allow about ten minutes.

  • You need: a shell, a working Docker daemon, and an image name or ID that is already local or resolvable by Docker.
  • It will not touch anything: docker image inspect reads metadata only. It does not start a container, change an image, or require root when your account already has Docker socket access. Membership of the docker group is effectively privileged access to the daemon, so do not add users to it just for convenience.

1. Confirm the command and the image

Check the installed command before relying on a copied example. This is read-only and normally needs no elevated privileges:

$ docker --version
Docker version 29.8.1, build 4a63305
$ docker image inspect --help

The syntax is docker image inspect [OPTIONS] IMAGE [IMAGE...]. The final argument is an image reference, such as alpine:latest, a repository digest, or an image ID. Tags are mutable names, so use a digest or a full ID when you need an auditable result.

Checkpoint

Verify that the reference resolves before building a longer command:

$ docker image inspect alpine --format '{{.Id}}'
sha256:294b683cb724975bec92580e1e685676bd4b50dba910ddb8c51d4cabeaec77e6

Your ID will differ if the local image has changed. If Docker says the image is not found, check the spelling and tag. Inspecting a reference can make Docker contact a registry when another command has pulled it first, but this command never modifies the image itself.

2. Read the complete metadata once

Run the command without --format when you need context rather than one field. The result is JSON-like output containing the ID, tags, digests, creation time, configuration, architecture, operating system and layer information:

$ docker image inspect alpine
[
    {
        "Id": "sha256:294b683cb724...",
        "RepoTags": [
            "alpine:3",
            "alpine:latest"
        ],
        "Architecture": "amd64",
        "Os": "linux",
        "Config": {
            "Cmd": [
                "/bin/sh"
            ]
        }
    }
]

The abbreviated ID above is for readability. Do not parse this display with line-oriented tools: nested arrays and objects make that brittle, and the exact field set varies with the image and Docker version. Reach for a format template instead when a value has to feed another command or check.

3. Extract identity and platform fields

The -f and --format options accept a Go template. Keep the template in single quotes so the shell passes its braces and dots unchanged:

$ docker image inspect --format '{{.Id}} {{.Os}}/{{.Architecture}}' alpine
sha256:294b683cb724975bec92580e1e685676bd4b50dba910ddb8c51d4cabeaec77e6 linux/amd64
$ docker image inspect --format '{{json .RepoTags}}' alpine
["alpine:3","alpine:latest"]

These examples use fields observed in the installed image. A missing field can render as an empty value, and a field's shape can differ from what you expect. Test a template against one known image before it goes anywhere near a script.

For a machine-readable result, use Docker's special json format instead of building your own template:

$ docker image inspect --format json alpine

That output is safer to feed a real JSON parser than trying to extract values from the default multi-line display, particularly once you start inspecting several images at once.

4. Inspect more than one image deliberately

The command accepts one or more image arguments. Docker returns one metadata object per reference, in command order:

$ docker image inspect alpine:3 alpine:latest --format '{{.RepoTags}} {{.Id}}'
[alpine:3 alpine:latest] sha256:294b683cb724975bec92580e1e685676bd4b50dba910ddb8c51d4cabeaec77e6
[alpine:3 alpine:latest] sha256:294b683cb724975bec92580e1e685676bd4b50dba910ddb8c51d4cabeaec77e6

The exact values depend on the local cache. When tags point at the same image, the IDs match. Treat a tag match as useful evidence, not a permanent guarantee: a later pull can move a tag to a different ID.

For a script, fail on an unresolved reference and check the status immediately:

$ if ! docker image inspect 'IMAGE_REFERENCE' >/dev/null; then
>     printf 'image not available: %s\n' 'IMAGE_REFERENCE' >&2
>     exit 1
> fi
$ printf 'image metadata is available\n'
image metadata is available

Replace IMAGE_REFERENCE with a value you control, and quote it if it comes from a variable. Never pass arbitrary user input as a sequence of extra Docker options.

5. Check a multi-platform image

The installed command supports --platform for inspecting a specific platform of a multi-platform image. Use an explicit value such as linux/amd64 when the platform matters:

$ docker image inspect --platform linux/amd64 --format '{{.Os}}/{{.Architecture}}' alpine
linux/amd64

The platform is written as os[/arch[/variant]]. Docker errors if the image or server cannot handle the requested platform, or if it does not match, and that error is useful evidence in itself: do not silently drop --platform just to make a failing check pass.

A platform check is not proof that an application will run correctly. It identifies the image variant Docker selected. Runtime behaviour still depends on the host kernel, mounts, capabilities and application configuration.

Common traps

  • Daemon connection error. The CLI could not reach Docker. Check the service and socket for your distribution, then rerun the harmless metadata command. Do not reach for sudo first: it can change which Docker configuration and socket the CLI uses, and it can hide a permissions problem.
  • Image not found. Usually the reference is wrong or the image is not present. Confirm the complete repository and tag. If pulling is the right move, treat that as a separate state-changing operation and verify the digest afterwards. This guide never pulls, deletes or retags anything.
  • Template error or empty value. That is a data-shape problem, not a syntax mystery. Start with the full inspection, confirm the field name, then add one expression at a time. Keep the original reference and expected ID in your logs when the check is part of a deployment gate.

Done means

  • Confirmed the version. You checked the installed Docker CLI version and that the image reference resolves.
  • Told tags from IDs. You can distinguish a mutable tag from a stable image ID or digest.
  • Read full metadata once. You extracted identity, operating system and architecture with a template afterwards.
  • Checked a platform on purpose. You can request a specific platform and treat a mismatch as a real diagnostic result.
  • Failed cleanly. Your checks fail clearly when an image is unavailable, without pulling, deleting or changing anything.