You can use the --filter option with the docker inspect command to limit the output based on specific criteria. However, it's important to note that docker inspect itself does not support filtering in the same way that commands like docker ps do. Instead, you can use jq or other command-line tools to parse the JSON output.
Here’s how you can use docker inspect with a filter:
-
Inspect a container and filter the output using
jq:First, ensure you have
jqinstalled. Then you can run:docker inspect CONTAINER_ID_OR_NAME | jq '.[].State.Status'This command will show you the status of the specified container.
-
Using
--formatoption:You can also use the
--formatoption to filter the output directly:docker inspect --format='{{.State.Status}}' CONTAINER_ID_OR_NAME
This will return just the status of the specified container without the full JSON output. Replace CONTAINER_ID_OR_NAME with the actual ID or name of the container you want to inspect.
