Linux command
docker-inspect 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Inspect a container
docker inspect [container]
Inspect an image
docker inspect [image]
Get specific field
docker inspect -f '{{.State.Status}}' [container]
Get IP address
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' [container]
Output as JSON
docker inspect --format '{{json .Config}}' [container]
说明
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.
参数
- -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).
FAQ
What is the docker-inspect command used for?
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.
How do I run a basic docker-inspect example?
Run `docker inspect [container]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -f, --format _string_ do in docker-inspect?
Format output using Go template.