Skip to content

Instantly share code, notes, and snippets.

@Pelirrojo
Forked from beeva-manueldepaz/armagedocker.sh
Last active August 20, 2017 19:21
Show Gist options
  • Save Pelirrojo/71225609c71e5f73cfa88ac8934c5939 to your computer and use it in GitHub Desktop.
Save Pelirrojo/71225609c71e5f73cfa88ac8934c5939 to your computer and use it in GitHub Desktop.
Script to delete all the images, containers and logs (path oriented to OsX)
#!/bin/sh
# HowTo
# Put it at /usr/local/bin/armaggeDocker.sh
# Give permissions: chmod a+x /usr/local/bin/armaggeDocker.sh
read -p "This will stop and delete all running containers and local images. Are you sure that you want to continue? (y/n) " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
# Delete containers
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
# Delete images
docker rmi $(docker images -q)
#docker rmi $(docker images -q --filter "dangling=true")
# Delete volumes
docker volume ls -q | xargs docker volume rmw
# Delete all logs
rm /Users/$(whoami)/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2
rm /Users/$(whoami)/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/syslog
rm -rf /Users/$(whoami)/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/log
mkdir /Users/$(whoami)/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/log
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment