Skip to content

Instantly share code, notes, and snippets.

@rossmacarthur
Forked from JeffBelback/docker-destroy-all.sh
Last active September 6, 2018 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rossmacarthur/579d02802b1cc17baed07753d09f5009 to your computer and use it in GitHub Desktop.
Save rossmacarthur/579d02802b1cc17baed07753d09f5009 to your computer and use it in GitHub Desktop.
Destroy all Docker Containers and Images
#!/usr/bin/env bash
containers=$(docker ps -a -q)
# Stop all containers
if [ ! -n "$containers" ]; then
docker stop $containers
docker rm $containers
fi
images=$(docker images -a -q)
# Delete all images
if [ ! -n "$images" ]; then
docker rmi $images
fi
# Delete all networks
docker network prune -f
# Delete all volumes
docker volume prune -f
# Prune system
docker system prune -f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment