Skip to content

Instantly share code, notes, and snippets.

@linki
Last active August 29, 2015 14:16
Show Gist options
  • Save linki/196ac6bf32e7c4f4652b to your computer and use it in GitHub Desktop.
Save linki/196ac6bf32e7c4f4652b to your computer and use it in GitHub Desktop.
remove superflous images
#!/usr/bin/env bash
images=( $(docker images | awk '{ print $1 }' | sort | uniq -c | awk '{print $2}' ) )
for i in "${images[@]}"
do
echo "removing superflous images for" $i
docker images | grep "$i" | tail -n +2 | grep -v latest | awk '{print $1 ":" $2}' | xargs docker rmi
done
@linki
Copy link
Author

linki commented Feb 27, 2015

make sure to remove containers before

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