Sort by memory usage in docker stats

To sort by Mem Usage field you can use the following command:

GNU/Linux:

docker stats --no-stream --format "table {{.Name}}\t{{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}" | sort -k 4 -h

MacOS:

docker stats --no-stream --format "table {{.Name}}\t{{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.M‌​emPerc}}" | sort -k 9 -n

Check this link to view all available options to --format option of docker stats: https://docs.docker.com/engine/reference/commandline/stats/#formatting

Leave a Comment