Skip to content
Software capabilities

Docker capability

Inspect Docker container configuration

Inspect a container to see its configured image, environment, mounts, and network settings. Use the CLI for a quick lookup and the Engine API or Docker SDK when a program needs the fields.

Documentation reviewed

Ways to do it

CLI

docker container inspect <container>

Print the container’s details as JSON. Pass --format to select the field you need.

Requirements
Docker CLI connected to the daemon containing the container name or ID.
Limitations
Size fields require --size. The default metadata describes the container configuration and state.

Example

docker container inspect --format '{{.Config.Image}}' "$CONTAINER"
Read source: Docker CLI container inspect

API

GET /containers/{id}/json

Read the engine’s container metadata as a JSON response.

Requirements
Authorized access to the Docker daemon and the container name or ID.
Limitations
Use size=true if you need SizeRw and SizeRootFs in the response.
Read source: Docker Engine API ContainerInspect

SDK

client.containers.get() and Container.attrs

Get a container object by ID or name in Python and read its inspected fields from attrs.

Requirements
An authorized Docker SDK client and the container name or ID.
Limitations
The SDK caches attrs on the object. Call reload() before reading fields that might have changed.
Read source: Docker SDK for Python container objects