Skip to content

Instantly share code, notes, and snippets.

@sadortun
Forked from yixizhang/cleanup-docker.sh
Created November 16, 2016 05:41
Show Gist options
  • Save sadortun/92a9a73524df3390e9e8b7d3625a0f7c to your computer and use it in GitHub Desktop.
Save sadortun/92a9a73524df3390e9e8b7d3625a0f7c to your computer and use it in GitHub Desktop.
Cleanup docker disk space https://lebkowski.name/docker-volumes/
#!/bin/bash
# remove exited containers:
docker ps --filter status=dead --filter status=exited --filter status=created -aq | xargs -r docker rm -v
# remove unused images:
docker images --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