Skip to content

Instantly share code, notes, and snippets.

@andyrbell
Last active September 11, 2022 22:36
Show Gist options
  • Star 44 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save andyrbell/f30ae74c0eff82ae52238f4a7df9a313 to your computer and use it in GitHub Desktop.
Save andyrbell/f30ae74c0eff82ae52238f4a7df9a313 to your computer and use it in GitHub Desktop.
Sort docker images by size desc
#!/bin/sh
docker images --format '{{.Size}}\t{{.Repository}}\t{{.Tag}}\t{{.ID}}' | sed 's/ //' | sort -h -r | column -t
@emsi
Copy link

emsi commented Feb 27, 2020

I had to replace the decimal separator in dockers {{.Size}} which seems to be always a dot, with the one of my locale to make sort -h work properly.

Setting locale collate would do the trick as well. Something like this should work too:
docker images | LC_COLLATE=C.UTF-8 sort -k7 -hr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment