Skip to content

Instantly share code, notes, and snippets.

@digitalist
Last active June 24, 2021 05:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digitalist/abf3320fa5ad937015cca15920e25acc to your computer and use it in GitHub Desktop.
Save digitalist/abf3320fa5ad937015cca15920e25acc to your computer and use it in GitHub Desktop.
removes restart policy and kills all docker containers and volumes
#!/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