Skip to content

Instantly share code, notes, and snippets.

@dz-s
Created May 29, 2019 11:06
Show Gist options
  • Save dz-s/586c0b576d1afc1bf3962732c57d761a to your computer and use it in GitHub Desktop.
Save dz-s/586c0b576d1afc1bf3962732c57d761a to your computer and use it in GitHub Desktop.
removecontainers() {
docker stop $(docker ps -aq)
docker rm $(docker ps -aq)
}
armageddon() {
removecontainers
docker network prune -f
docker rmi -f $(docker images --filter dangling=true -qa)
docker volume rm $(docker volume ls --filter dangling=true -q)
docker rmi -f $(docker images -qa)
}
@treygilliland
Copy link

I use this script a TON, but wanted to add a version that doesn't remove the volumes in case anyone wants that functionality:

removecontainers() {
    docker stop $(docker ps -aq)
    docker rm $(docker ps -aq)
}

armageddon() {
    removecontainers
    docker network prune -f
    docker rmi -f $(docker images --filter dangling=true -qa)
    docker rmi -f $(docker images -qa)
}

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