Skip to content

Instantly share code, notes, and snippets.

@atoa
Last active February 10, 2017 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atoa/96443589a465b47d62b7e4fad22374ba to your computer and use it in GitHub Desktop.
Save atoa/96443589a465b47d62b7e4fad22374ba to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# from: http://blog.yohanliyanage.com/2015/05/docker-clean-up-after-yourself/
#https://lebkowski.name/docker-volumes/
#docker rm -v $(docker ps -a -q -f "status=exited")
#docker rmi $(docker images -f "dangling=true" -q)
docker system df
# remove unused volumes:
echo '[INFO] removing unused volumes'
docker volume ls -qf dangling=true | xargs -r docker volume rm
# remove exited containers:
echo '[INFO] removing exited containers'
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v
# remove unused images:
echo '[INFO] removing unused images'
docker images --filter "dangling=true" -q | xargs -r docker rmi
echo '[INFO] running system prune'
docker system prune
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment