Created
June 29, 2019 04:42
-
-
Save timjonesdev/5ea97bb10eddd311e57b1a5a0c0f9432 to your computer and use it in GitHub Desktop.
A cleanup script for docker resources, if you don't have `docker system prune` available. WARNING: This will delete all containers, images, and volumes.
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 | |
echo "Running docker cleanup script" | |
echo "Stopping all containers" | |
docker stop $(docker ps -a -q) # Stop all containers | |
echo "Removing stopped containers" | |
docker rm $(docker ps -a -q) # Remove all stopped containers | |
echo "Removing all images" | |
docker rmi $(docker images -a -q) # Remove all images | |
echo "Removing all volumes" | |
docker volume rm $(docker volume ls -qf dangling=true) # Remove all volumes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment