-
-
Save andyrbell/f30ae74c0eff82ae52238f4a7df9a313 to your computer and use it in GitHub Desktop.
| #!/bin/sh | |
| docker images --format '{{.Size}}\t{{.Repository}}\t{{.Tag}}\t{{.ID}}' | sed 's/ //' | sort -h -r | column -t |
docker images | sort -k7 -h
Showing & keeping the leading column title where they are:
docker images | awk 'NR<2{print $0;next}{print $0| "sort -k7 -hr"}'
Add | head to get only the biggest ones
docker images | sort -k7 -h
@quantonganh Like a pro! :) Kudos.
To be clear, its -k7, not -k5, because there are generally two spaces in the preceding CREATED column
docker images | sort -k7 -h
@quantonganh Great one! I just added an -r to show the biggest image first:
docker images | sort -k7 -h -r
docker images | sort -k7 -h
@quantonganh I referenced your command in another post.
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.
docker images --format '{{.Size}}\t{{.Repository}}:{{.Tag}}\t{{.ID}}' | sed 's/\./,/' | sort -hr | column -t
Note: the sed command blindly replaces the first "." per line.
I had to replace the decimal separator in dockers
{{.Size}}which seems to be always a dot, with the one of my locale to makesort -hwork 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

@cuongtransc thanks. have updated with the
column -t