Formatting and filtering the output of any command is always useful. In Docker commands with long lists or outputs, it is really necessary. Let's begin with formatting some command output.
Almost all actions that represent or show any kind of information can be formatted. Docker uses Go templates to modify the output format. It is very useful to be able to format output for our specific needs. We will use the table format here. Each column will represent a specified key.
We will consider a brief example output listing all the deployed containers in a host using docker container ls with the table format:
$ docker container ls --all --format "table {{.Names}}: {{.Image}} {{.Command}}" --no-trunc
NAMES: IMAGE COMMAND
loving_diffie: alpine "/bin/sh"
recursing_fermi: alpine "/bin/sh"
silly_payne: centos "/bin/bash"
wonderful_visvesvaraya: centos "/bin/bash"
optimistic_lamarr: centos "/bin/bash"...