Created
August 7, 2014 04:55
-
-
Save jeffutter/05b78e1e5c8964179830 to your computer and use it in GitHub Desktop.
Clean Old Docker Containers/Images
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
#!/bin/bash | |
containers=$( (docker ps ; docker ps -a ) | tr -s ' ' | sort | uniq -u |grep -v '_data'|grep -v "CONTAINER" | awk '{print $1}' ) | |
if [[ -n $containers ]]; then | |
docker rm $containers | |
fi | |
images=$(docker images |grep '<none>'| awk '{print $3}') | |
if [[ -n $images ]]; then | |
docker rmi $images | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment