Skip to content

Instantly share code, notes, and snippets.

@thecocce
Forked from JeffBelback/docker-destroy-all.sh
Created August 21, 2019 09:49
Show Gist options
  • Select an option

  • Save thecocce/06900dfa46ebd9d076a250f54c817d7f to your computer and use it in GitHub Desktop.

Select an option

Save thecocce/06900dfa46ebd9d076a250f54c817d7f 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