docker inspect
The docker inspect command is used to return detailed information about Docker objects such as containers, images, volumes, and networks in JSON format. This command is useful for debugging and understanding the configuration and state of Docker objects.
Basic Syntax
Key Options and Parameters
-f, --format: Format the output using a Go template.
docker inspect -f '{{.State.Running}}' mycontainer--type: Return JSON for specified type (e.g., container, image, volume, network).
docker inspect --type container mycontainer
Examples
Inspecting a Container
docker inspect mycontainerThis command returns detailed information about the container named
mycontainer.Inspecting an Image
docker inspect myimageThis command returns detailed information about the image named
myimage.Inspecting a Volume
docker inspect myvolumeThis command returns detailed information about the volume named
myvolume.Inspecting a Network
docker inspect mynetworkThis command returns detailed information about the network named
mynetwork.Formatting the Output
docker inspect -f '{{.State.Running}}' mycontainerThis command returns the running state of the container named
mycontainerusing a Go template.Specifying the Type
docker inspect --type container mycontainerThis command returns JSON formatted information specifically for the container named
mycontainer.
Conclusion
The docker inspect command is essential for retrieving detailed information about Docker objects. Understanding its options and parameters allows you to effectively debug and manage your Docker containers, images, volumes, and networks.