The default docker ps output can contain more information than you actually need.
With the --format option, you can choose exactly which columns to display.
For example:
docker ps --format "table {{.Ports}}\t{{.Status}}\t{{.Names}}"This displays only the Ports, Status, and Names columns, making the output much easier to scan.
Note: It can be configured with other columns that are relevant to you (e.g. ID)
Example: docker ps

Example: docker ps --format "table {{.Ports}}\t{{.Status}}\t{{.Names}}"
How to turn this into command into a handy CLI alias (e.g. dps)
1. Add the alias to your shell configuration
For Bash, open either ~/.bashrc or ~/.bash_profile:
nano ~/.bashrc
Then add:
alias dps='docker ps --format "table {{.Ports}}\t{{.Status}}\t{{.Names}}"'
2. Reload the configuration
Run:source ~/.bashrc
If you added the alias to.bash_profile, run:source ~/.bash_profile
3. Use the alias
From now on, simply run:
dps
and you’ll get the customized docker ps output without having to type the full command every time.
Tip: You can customize the format further by using other Docker placeholders such as {{.ID}}, {{.Image}}, {{.Command}}, {{.CreatedAt}}, and {{.RunningFor}}.

Post Views: 57
