Skip to content

Instantly share code, notes, and snippets.

@gobinathm
Forked from JeffBelback/docker-destroy-all.sh
Created June 4, 2020 04:50
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 gobinathm/14b7fad9c1ee1d18513886d81ae1bdb2 to your computer and use it in GitHub Desktop.
Save gobinathm/14b7fad9c1ee1d18513886d81ae1bdb2 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