Skip to content

Instantly share code, notes, and snippets.

@andreiashu
Created October 1, 2017 01:46
Show Gist options
  • Save andreiashu/47ec623146ad0fb3023102fbbbc8fe94 to your computer and use it in GitHub Desktop.
Save andreiashu/47ec623146ad0fb3023102fbbbc8fe94 to your computer and use it in GitHub Desktop.
WARNING! this will obliterate absolutely all your Docker containers and images. I'm using it on an OSX installation to get rid of the pesky "No space left on device" error (with plenty of free space on my disk). Put it in your ~/.bashrc or ~/.zshrc and run it with `pwndocker`
# PWN that sucker!
# Warning: completely obliterates Docker: removes all containers, images and volumes
# add this function to your ~/.bash_profile or ~/.zshrc (or equivalent)
pwndocker() {
echo -n "You sure you want to pwn Docker (y/n)? "
read answer
if echo "$answer" | grep -iq "^y$" ;then
[[ -n $(docker ps -qa) ]] && docker kill $(docker ps -qa)
[[ -n $(docker ps -qa) ]] && docker rm -v $(docker ps -qa)
[[ -n $(docker images -q) ]] && docker rmi -f $(docker images -q)
echo "Docker pwned!"
else
echo No
fi
}
@tzapu
Copy link

tzapu commented Oct 1, 2017

Might as well use docker stop instead of kill. If you have local volumes there s less risk of potential corruption i guess

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