Created
August 30, 2017 17:58
-
-
Save xiongtx/fbf915d420e0305d43372a0723ae0c5c to your computer and use it in GitHub Desktop.
Docker-related stuff
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
function rm-old-images() { | |
IMAGESINFO=$(sudo docker images --no-trunc --format '{{.ID}} {{.Repository}} {{.Tag}} {{.CreatedSince}}' |grep -E " (weeks|months|years)") | |
TAGS=$(echo "$IMAGESINFO" | awk '{ print $2 ":" $3 }' ) | |
IDS=$(echo "$IMAGESINFO" | awk '{ print $1 }' ) | |
for t in $TAGS; do sudo docker rmi $t; done | |
for i in $IDS; do sudo docker rmi $i; done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment