How to use --format
option of docker inspect
to get its output as a table.
Following the documentation I used --format 'table ...'
as an option with docker ps
and it worked fine, but docker inspect
seems to ignore it.
example:
echo "docker ps as table"
docker ps -a --format 'table {{.Names}}t{{.Image}}'
echo "docker inspect as table"
docker ps --quiet | xargs --no-run-if-empty docker inspect
--format 'table {{.Name}}t{{.Config.Image}}'
produces the output:
docker ps as table
NAMES IMAGE
tmp-php-7.3-cli-buster tmp-php:7.3-cli-buster
tmp-mysql-8.0.19-client mysql:8
tmp-mysql-8.0.19 tmp-mysql:8.0.19
tmp-nginx-1.17.8 tmp-nginx:1.17.8
tmp-php-7.3-fpm-buster tmp-php:7.3-fpm-buster
tmp-node-13.8.0-buster tmp-node:13.8.0-buster
docker inspect as table
table /tmp-php-7.3-cli-busterttmp-php:7.3-cli-buster
table /tmp-mysql-8.0.19-clienttmysql:8
table /tmp-mysql-8.0.19ttmp-mysql:8.0.19
table /tmp-nginx-1.17.8ttmp-nginx:1.17.8
table /tmp-php-7.3-fpm-busterttmp-php:7.3-fpm-buster
table /tmp-node-13.8.0-busterttmp-node:13.8.0-buster
2
Answers
Looks like
docker inspect
currently can’t ouput tables, see this GitHub issue:I got here because I’ve tried to output table too, but unfortunately, all I can do is quote the comment from the issue:
I managed to get a "table"-like output similar to
docker stats
. Mainly by utilizing thecolumn
command.For example with this command:
Or if you also want some fancy headings: