Skip to content

Instantly share code, notes, and snippets.

@karantir
Last active January 16, 2017 20:41
Show Gist options
  • Save karantir/f2f420e8e2e2d43a6483a33d7e196e7d to your computer and use it in GitHub Desktop.
Save karantir/f2f420e8e2e2d43a6483a33d7e196e7d to your computer and use it in GitHub Desktop.
Remove exited containers, orphanted images and volumes
#!/bin/bash
# Docker version >= 1.9
echo "Cleaning up exited containers..."
docker ps -a -qf status=exited | xargs -r docker rm
echo "Cleaning up orphanted images..."
docker images -qf dangling=true | xargs -r docker rmi
echo "Cleaning up orphanted 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