Skip to content

Instantly share code, notes, and snippets.

@wrparker
Created December 5, 2017 21:05
Show Gist options
  • Select an option

  • Save wrparker/f2b1c4026c2be0af5253fc25fc8c4429 to your computer and use it in GitHub Desktop.

Select an option

Save wrparker/f2b1c4026c2be0af5253fc25fc8c4429 to your computer and use it in GitHub Desktop.
Bash script that removes 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