Skip to content

Instantly share code, notes, and snippets.

@geerteltink
Created November 2, 2016 14:03
Show Gist options
  • Save geerteltink/3d71130489633ad447e9d9a431eaec64 to your computer and use it in GitHub Desktop.
Save geerteltink/3d71130489633ad447e9d9a431eaec64 to your computer and use it in GitHub Desktop.
Bash script to remove Docker containers, images and volumes.
#!/bin/bash
# remove exited containers:
docker ps -aq --filter status=dead --filter status=exited | xargs -r docker rm -v
# remove unused images:
docker images -qf dangling=true --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi
# remove unused volumes:
docker volume ls -qf dangling=true | xargs -r docker volume rm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment