If you’ve been using Docker for a while, you may have noticed that it can quickly use up a lot of disk space. Especially after testing out a few images, updating existing ones you may find your host slowly but surely filling up.
In this quick tip, I’ll show you how to use the built-in command docker system prune
to clear up space used by Docker.
docker system prune
do?To quote the official documentation: this command “removes unused data”.
In practice, this means that it will remove:
I’ve found, that especially dangling images can use up a lot of space. If you are using my quicktip for updating your Home Assistant installation this can quickly use up a lot of space on your SD card.
--all, -a
- Remove all unused images not just dangling ones
--force, -f
- Do not prompt for confirmation
--volumes
- Prune volumes
Be careful when using the --volumes
option. This will remove all volumes that are not used by any containers and could potentially delete data you need!
To use the command, simply run it in your terminal with your wanted options. For example, to remove all unused images and dangling containers, you would run:
docker system prune --all
Using the built-in command docker system prune
is a quick and easy way to clear up space used by Docker. It’s a good idea to run it every once in a while to keep your host running smoothly and efficiently. On my Raspberry Pi I run it after updating my existing containers.
You might find these related articles helpful or interesting, make sure to check them out!
I hope this article helped you! If you have any questions, hit me up on X 😊.