liveBook · Manning

Docker inspect

As explained in Learn Docker in a Month of Lunches, Second Edition

docker image inspect is a Docker CLI command that displays detailed metadata and configuration for a container image.

docker image inspect displays detailed metadata and configuration for a Docker image. With formatted output, it can expose image labels that record build information and provenance. section 11.3

Use the command to:

  • Check labels such as the application version, build number, and build tag. section 11.3
  • Trace an image from its CI job and source-code version through the image used in an environment. section 11.3
  • Select only the relevant metadata with a Go-template format expression instead of reading the full inspection output. section 11.3

Inspect image labels

After building an image with a build argument, run `docker image inspect -f '{{.Config.Labels}}' numbers-api`. The result lets you verify the labels applied during the build. section 11.3

cd ch11/exercises
# build both images:
docker compose `
 -f docker-compose.yml `
 -f docker-compose-build.yml `
 build
# check the labels for the web image:
docker image inspect -f '{{.Config.Labels}}' `
 diamol/ch11-numbers-api:2e-v3-build-local

Shows a Compose build followed by a formatted docker image inspect command that checks the API image labels. section 11.3

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Demonstrates formatted label queries and provenance checks, but does not detail the full image metadata schema.
Examples
Uses numbers-api images, build_number and build_tag labels, and a formatted inspection command.
What it assumes
Assumes a built Docker image and familiarity with Dockerfile labels, build arguments, or Compose build settings.
What you can do after
Diagnose image provenance by inspecting labels produced during Docker or Docker Compose builds.
How it connects
Connects Docker images with Docker Compose, Dockerfile build arguments, image labels, and continuous integration.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.