Created
March 14, 2017 19:12
-
-
Save tprado/12a863b2f92c43208ecdecfb059b39a1 to your computer and use it in GitHub Desktop.
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
docker_ps_exited() { | |
docker ps -a -q -f status=exited | |
} | |
docker_dangling_images() { | |
docker images -f 'dangling=true' -q | |
} | |
docker_cleanup() { | |
local pids | |
local images | |
pids=$(docker_ps_exited) | |
if [[ "$pids" == "" ]]; then | |
echo 'no containers to remove' | |
else | |
docker rm -v $pids | |
fi | |
images=$(docker_dangling_images) | |
if [[ "$images" == "" ]]; then | |
echo 'no images to remove' | |
else | |
docker rmi $images | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment