Last active
May 14, 2023 17:23
-
-
Save seiwonpark/a9a1dba5b088e16ef426155063222f64 to your computer and use it in GitHub Desktop.
reset.sh
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
#!/bin/bash | |
echo "[WARN] Removing all docker resources..." | |
read -p "Do you want to continue? [y/n] ? " -r ARG | |
if [[ $ARG =~ ^[Yy]$ ]]; then | |
[ $(docker ps | wc -l) -ne 1 ] && \ | |
echo "\n[INFO] Stopping containers..." && \ | |
docker stop $(docker ps -aq) | |
[ $(docker ps -a | wc -l) -ne 1 ] && \ | |
echo "\n[INFO] Removing containers..." && \ | |
docker rm $(docker ps -aq) | |
[ $(docker images | wc -l) -ne 1 ] && \ | |
echo "\n[INFO] Removing images..." && \ | |
docker rmi $(docker images -aq) | |
[ $(docker volume ls | wc -l) -ne 1 ] && \ | |
echo "\n[INFO] Removing volumes..." && \ | |
docker volume rm $(docker volume ls -q) | |
else | |
echo "\nTerminated process.\n\n" | |
fi | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ docker run -v $PWD:/temp psw9787/reset