Inspecting All Running Docker Containers
2020 October 29

I just discovered how to run inspect on all running docker containers.

Collecting them into a single JSON array

docker container ls | tail -n +2 | cut -f1 -d' ' | xargs docker inspect

Runs docker inspect once by using xargs to populate the list of arguments.

Collecting them into separate JSON arrays

docker container ls | tail -n +2 | cut -f1 -d' ' | while read id; do docker inspect $id ; done | jq 'length'

This version runs docker inspect for every container. This generates a series of arrays with a single machine in it.


Remember you can also subscribe using RSS at the top of the page!

Share this on → Mastodon Twitter LinkedIn Reddit

A selected list of related posts that you might enjoy:

*****
Written by Henry J Schmale on 2020 October 29
Hit Counter