Created
March 24, 2017 09:06
-
-
Save rhblind/0fa655b8e68e8343abac4fb5f2075acb 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
#!/usr/bin/env bash | |
EXITED=$(docker ps -q -f status=exited) | |
DANGLING=$(docker images -q -f "dangling=true") | |
if [ "$1" == "--dry-run" ] | |
then | |
echo "==> Would stop containers:" | |
echo $EXITED | |
echo "==> And images:" | |
echo $DANGLING | |
else | |
if [ -n "$EXITED" ] | |
then | |
docker rm $EXITED | |
else | |
echo "No containers to remove." | |
fi | |
if [ -n "$DANGLING" ] | |
then | |
docker rmi $DANGLING | |
else | |
echo "No images to remove." | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment