I haven't found any way to order my results when using docker ps
In my case I want to order by .Ports
docker ps -a --format "table {{.ID}}\t{{.Names}}\t{{.Ports}}"
How do I order the result?
I haven't found any way to order my results when using docker ps
In my case I want to order by .Ports
docker ps -a --format "table {{.ID}}\t{{.Names}}\t{{.Ports}}"
How do I order the result?
If it's enough to simply sort by output column, you can use the following:
I also added a code for skipping the table headers and sorting only ps output data.
Format and Order docker ps
List containers
Format
Synopsis
Display containers with their commands
Display containers with their labels in a table
Display containers with their node label in a table
I built a docker ps pretty print function that can be put into your
.bash_profile
or.bashrc
file that works somewhat like an alias fordocker ps
(with color output). @art-rock-guitar-superhero suggestions shows how to sort, but I've included this answer since typing the--format
options and piping into asort
every time is a bit tedious.usage:
$ docker ps -p
.EDIT: I added suggestions from the comments from @BrianVosburgh. Also, I kept forgetting to type
-p
so I switched the flag for this function to be-a
, which is my regular usage ofdocker ps
.