Created
October 4, 2019 07:49
-
-
Save jose-lpa/d96ce54afcae89cb6582bc9d379cbd72 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
clean_containers() { | |
containers=$(docker ps -q) | |
echo "Stopping any running containers..." | |
docker stop $containers | |
echo "Removing all containers..." | |
docker rm -v $containers 2>/dev/null | |
echo "Containers removed from system." | |
} | |
clean_images() { | |
echo "Removing Docker images..." | |
docker rmi --force $(docker images -q 2>/dev/null) 2>/dev/null | |
echo "All Docker images removed from system." | |
} | |
clean_environments() { | |
echo "Removing leftover volumes..." | |
docker volume rm --force $(docker volume ls -q) | |
echo "Pruning leftover networks..." | |
docker network prune --force | |
} | |
echo "Cleaning up Docker environment..." | |
clean_containers | |
clean_images | |
clean_environments | |
echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment