-
-
Save rossmacarthur/579d02802b1cc17baed07753d09f5009 to your computer and use it in GitHub Desktop.
Destroy all Docker Containers and Images
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 | |
containers=$(docker ps -a -q) | |
# Stop all containers | |
if [ ! -n "$containers" ]; then | |
docker stop $containers | |
docker rm $containers | |
fi | |
images=$(docker images -a -q) | |
# Delete all images | |
if [ ! -n "$images" ]; then | |
docker rmi $images | |
fi | |
# Delete all networks | |
docker network prune -f | |
# Delete all volumes | |
docker volume prune -f | |
# Prune system | |
docker system prune -f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment