Last active
June 24, 2021 05:05
-
-
Save digitalist/abf3320fa5ad937015cca15920e25acc to your computer and use it in GitHub Desktop.
removes restart policy and kills all docker containers and volumes
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
#!/bin/bash | |
echo 'removing docker services...' | |
docker service ls | awk {' print $1 '} | tail -n+2 > tmp.txt; for line in $(cat tmp.txt);\ | |
do docker service rm $line; \ | |
done; rm tmp.txt; \ | |
echo 'removing docker containers...'; \ | |
docker ps | awk {' print $1 '} | tail -n+2 > tmp.txt; for line in $(cat tmp.txt);\ | |
do docker kill $line; \ | |
docker update --restart=no $line; \ | |
done; rm tmp.txt; \ | |
echo 'pruning volumes, networks and whatever'; \ | |
docker system prune -a -f; \ | |
docker volume prune -f; \ | |
echo "done"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment