dockersortingterminal

How to sort my Docker images by size with `docker images` command?


To see all the images I have installed, I run docker images. I'd like to sort all my images by "SIZE". How can I do this? More generally, how does one sort the returned images by any parameter, such as "CREATED"


Solution

  • docker images supports --format flag to customize output -> https://docs.docker.com/engine/reference/commandline/images/#format-the-output

    Adding custom formatting and using sort does the trick:

    docker images --format "{{.ID}}\t{{.Size}}\t{{.Repository}}" | sort -k 2 -h