Skip to content

Instantly share code, notes, and snippets.

@cezar-popa
Forked from JeffBelback/docker-destroy-all.sh
Created June 25, 2021 11:32
Show Gist options
  • Save cezar-popa/3f155f8f7d13eda2e201eeea1ffad6d4 to your computer and use it in GitHub Desktop.
Save cezar-popa/3f155f8f7d13eda2e201eeea1ffad6d4 to your computer and use it in GitHub Desktop.
Destroy all Docker Containers and Images
#!/bin/bash
# Stop all containers
containers=`docker ps -a -q`
if [ -n "$containers" ] ; then
docker stop $containers
fi
# Delete all containers
containers=`docker ps -a -q`
if [ -n "$containers" ]; then
docker rm -f -v $containers
fi
# Delete all images
images=`docker images -q -a`
if [ -n "$images" ]; then
docker rmi -f $images
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment