How to sort or order results docker ps --format?

后端 未结 3 1756
既然无缘
既然无缘 2021-02-01 06:59

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}}         


        
3条回答
  •  面向向阳花
    2021-02-01 07:38

    If it's enough to simply sort by output column, you can use the following:

     docker ps -a --format "table {{.ID}}\t{{.Names}}\t{{.Ports}}" | (read -r; printf "%s\n" "$REPLY"; sort -k 3 )
    

    I also added a code for skipping the table headers and sorting only ps output data.

提交回复
热议问题