Created
October 20, 2016 09:38
-
-
Save slapers/576cdf2dfa53dfd2145c39d3c17e7dcd to your computer and use it in GitHub Desktop.
Cleanup docker images (keeps 10 last versions of each image)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| IMAGES=$(docker images --format "{{.Repository}}" | sort | uniq) | |
| for IMAGE in ${IMAGES}; do | |
| OLD=$(docker images ${IMAGE} --format "{{.ID}}" | tail -n +10) | |
| docker rmi ${OLD} | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment