In modern web development, it is not all that uncommon to find yourself working on different projects with different tech stacks, switching somewhat often within a relatively short period of time. Docker can help a lot with that.
However, with time you might end up having left over volumes, unused container builds and other assets taking up your precious SSD space.
The bellow tips are here to help you solve that.
Find out your reclaimable disk space
If you just wish to know how much disk space could be reclaimed:
$ docker system df
Reclaim your disk space
To remove everything that is not associated with any currently active containers, as well as all build-cache:
$ docker system prune -a --volumes
Reclaiming everything
If you want to completely reclaim everything:
- Stop all containers
$ docker container stop $(docker container ls -aq)
- Cleanup assets
$ docker system prune -a --volumes