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.