Skip to content

Instantly share code, notes, and snippets.

@jjmartres
Last active May 30, 2018 07:44
Show Gist options
  • Save jjmartres/ec58dbf5abbe9dfdc667fb6c7d568dec to your computer and use it in GitHub Desktop.
Save jjmartres/ec58dbf5abbe9dfdc667fb6c7d568dec to your computer and use it in GitHub Desktop.
Clean Docker
#!/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
sudo docker system prune --all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment