-
-
Save rcdevgames/b1177feb10914e0cba0bd732a0d58adc to your computer and use it in GitHub Desktop.
Reset Docker to a clean vanilla state
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 | |
# Reset Docker to a clean vanilla state. Will destroy all containers, images, networks, volumes, and cache. | |
[ $(docker ps | wc -l) -ne 1 ] && echo "Stopping all containers..." && docker stop $(docker ps | sed -n '1d;p' | awk -F" " '{print $1}') | |
[ $(docker ps -a | wc -l) -ne 1 ] && echo "Deleting all containers..." && docker rm $(docker ps -a | sed -n '1d;p' | awk -F" " '{print $1}') | |
[ $(docker images | wc -l) -ne 1 ] && echo "Deleting all images..." && docker image rm $(docker images | sed -n '1d;p' | awk -F" " '{print $3}') | |
echo "Pruning networks, volumes, and cache..." && docker system prune -a -f --volumes | |
echo "Docker is back to Vanilla... COMPLETE!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment