LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

docker-inspect

return low-level information on Docker objects

TLDR

Inspect a container
$ docker inspect [container]
copy
Inspect an image
$ docker inspect [image]
copy
Get specific field
$ docker inspect -f '{{.State.Status}}' [container]
copy
Get IP address
$ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' [container]
copy
Output as JSON
$ docker inspect --format '{{json .Config}}' [container]
copy

SYNOPSIS

docker inspect [options] name|id [name|id...]

DESCRIPTION

docker inspect returns low-level information on Docker objects including containers, images, volumes, and networks. Output is JSON by default, an array of result objects, one per argument.The --format flag accepts a Go template for extracting specific fields, useful in shell scripts to capture values like IP addresses, mount points, or exit codes. The {{json .Field}} template emits raw JSON for a sub-object. The --type flag disambiguates when an image and container share the same name.

PARAMETERS

-f, --format string

Format output using Go template.
-s, --size
Display total file sizes (containers only).
--type string
Return JSON for specified type (container or image).

CAVEATS

When multiple objects share a name, --type must be used to disambiguate. For containers, --size adds SizeRw and SizeRootFs fields but is expensive on large filesystems. The output schema differs between containers, images, networks, and volumes, so format templates are not portable across object types.

SEE ALSO

Copied to clipboard
Kai