Skip to content

Instantly share code, notes, and snippets.

@grvcoelho
Created December 9, 2016 10:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save grvcoelho/7ff3e9c53b9af059da6f05bef3ba9f33 to your computer and use it in GitHub Desktop.
Save grvcoelho/7ff3e9c53b9af059da6f05bef3ba9f33 to your computer and use it in GitHub Desktop.
Some scripts to cleanup docker disk space

Stop all containers

$ docker stop (docker ps -aq)
$ docker rm (docker ps -aq)

Remove unused images and containers

$ docker rm -v (docker ps -aqf status=exited)
$ docker rmi (docker images -qf dangling=true)

Remove unused volumes (shared volumes will be list after this)

$ docker volume rm (docker volume ls -qf dangling=true)
$ docker run -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker:/var/lib/docker --rm martin/docker-cleanup-volumes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment