Last active
March 8, 2018 07:18
-
-
Save lunarxlark/05b2bdf250bb0f72e96fd4d152b731c4 to your computer and use it in GitHub Desktop.
docker buildで出たゴミのお掃除 ref: https://qiita.com/lunarxlark/items/9fcca4be330a9ef4a6df
This file contains 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
GARBAGE=`docker images | grep "^$IMG " | awk '{ print $3 }'` | |
for CONTAINER in $GARBAGE | |
do | |
docker ps -a | grep $CONTAINER | awk '{ print $1 }' | xargs docker rm | |
done |
This file contains 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
IMAGES=$* | |
for IMG in $IMAGES | |
do | |
GARBAGE=`docker images | grep "^$IMG " | awk '{ print $3 }'` | |
for CONTAINER in $GARBAGE | |
do | |
docker ps -a | grep $CONTAINER | awk '{ print $1 }' | xargs docker rm | |
done | |
done |
This file contains 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
# docker image cleaner | |
# delete <none> images. | |
# delete container use <none> image. | |
GARBAGE_CONTAINERS=`docker images | grep "none" | awk '{ print $3 }'` | |
for CONTAINER in $GARBAGE_CONTAINERS | |
do | |
docker ps -a | grep $CONTAINER | awk '{ print $1 }' | xargs docker rm | |
done | |
docker images | grep "none" | awk '{ print $3}' | xargs docker rmi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment