Skip to content

Instantly share code, notes, and snippets.

@henvo
Last active May 20, 2018 13:42
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 henvo/99ce2ea25818ff039515222b7e18c3e1 to your computer and use it in GitHub Desktop.
Save henvo/99ce2ea25818ff039515222b7e18c3e1 to your computer and use it in GitHub Desktop.
This script stops and removes all docker containers and their images
#!/bin/bash
# WARNING: This script will remove all containers and images
echo -n "Do you want to factory-reset your docker (Y/n)? "
read answer
if [ "$answer" != "${answer#[Yy]}" ] ;then
# Stop all containers
docker stop $(docker ps -q)
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
else
echo Ok, bye
fi
@henvo
Copy link
Author

henvo commented May 20, 2018

Run this script via:
bash <(curl -sL https://bit.ly/2wYmHyf)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment