Inspect a specific type of object
In the previous steps, you used docker inspect
on containers. However, docker inspect
is a versatile command that can be used to inspect various Docker objects, including images, networks, and volumes.
To inspect an object other than a container, you need to specify the object type before the object's name or ID. The syntax is docker inspect <object_type> <object_name_or_id>
.
Let's inspect the nginx
image you pulled earlier.
First, list your images to get the image ID or name:
docker images
Find the nginx
image and note its REPOSITORY, TAG, or IMAGE ID.
Now, inspect the nginx
image. You can use the image name and tag (e.g., nginx:latest
) or the image ID. Replace <image_name_or_id>
with the appropriate value.
docker inspect image <image_name_or_id>
This will output detailed information about the nginx
image, including its layers, configuration, and metadata. Notice that the structure of the output is different from inspecting a container, as it reflects the properties of an image.
Next, let's inspect a Docker network. Docker creates default networks. You can list them using docker network ls
.
docker network ls
You will likely see networks like bridge
, host
, and none
. Let's inspect the bridge
network.
docker inspect network bridge
This command will show details about the bridge
network, including its configuration, connected containers, and IP addressing information.
Finally, let's inspect a Docker volume. If you don't have any volumes, you can create one.
docker volume create myvolume
Now, inspect the volume you just created.
docker inspect volume myvolume
This will display information about the myvolume
, such as its driver, mount point, and scope.
By specifying the object type (container
, image
, network
, volume
, etc.), you can use docker inspect
to get detailed information about different components of your Docker environment.