Skip to content

Instantly share code, notes, and snippets.

@scorsi
Last active May 27, 2019 11:07
Show Gist options
  • Save scorsi/fb6db4327eede882a784ff61ecd6ed6b to your computer and use it in GitHub Desktop.
Save scorsi/fb6db4327eede882a784ff61ecd6ed6b to your computer and use it in GitHub Desktop.
## STOP all containers
echo "Stoping all running containers"
docker ps -q | xargs --no-run-if-empty docker stop 2> /dev/null
## RM all containers
echo "Removing all containers"
docker ps -q -a --no-trunc --filter "status=exited" | xargs --no-run-if-empty docker rm 2> /dev/null
## RM all volumes
echo "Removing all volumes"
docker volume ls -q -f "dangling=true" | xargs --no-run-if-empty docker volume rm 2> /dev/null
## RM all networks
echo "Removing all networks"
docker network ls | awk '$3 == "bridge" && $2 != "bridge" { print $1 }' | xargs --no-run-if-empty docker network rm 2> /dev/null
## RM all images
echo "Removing all images"
docker image ls -q -a --no-trunc | xargs --no-run-if-empty docker image rm 2> /dev/null
## Purging docker
#echo "Purging Docker"
#docker system prune -a -f 2> /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment