Docker Disk Space Explosion and How to Clean It Up

At the spring cleaning of my computers, I noticed that one device I had nearly no disk space left. After removing old files and the usual suspects (like Windows updates) I found that Docker uses the most space.

While Docker Desktop for Windows showed me a disk usage of around 50 GB, TreeSize found 124 GB – far too much for the few containers that run on this machine. To clean-up the storage, I first tried the prune command to remove unused data:

WARNING! This will remove:
– all stopped containers
– all networks not used by at least one container
– all dangling images
– all dangling build cache

Are you sure you want to continue? [y/N] y
Deleted Containers:
0f8848582b4e694d3b1a53e3b8f322****949ce92699763fcaf1bca8a
ca6e4bcf821fcf268d394fa626c2d6****ea09afa0f13c6483b325fff
62ecb12b65c86aea19645aea3eeaf9****574ee69b9a6eb9c3809c0a9
4a9f42cfb665f382aba9c83afe645f****599975a3ac5fbe70a1cd54a

Total reclaimed space: 687.2MB

I had higher expectations that the mere 690 MB it cleaned up. Next, I tried the Docker Desktop for Windows and use its clean-up function in Images / Clean up.

Select all containers to be removed

That approach ended after a few seconds in this error:

Docker returned an internal server error

I restarted my computer, run Docker Desktop again and then tried once more the clean-up function. This time I selected all containers and images and it run for a few minutes. The success message informed me that Docker got rid of 42.67 GB:

Total reclaimed space is 42.67 GB

That was much better. As I rechecked my disk with TreeSize it showed that Docker cleaned up 120 GB. Success!

Only delete all Docker images and containers when you have a fast internet connection or no longer work with your old projects. Otherwise, it will take a lot of time to redownload the images you need. Even when you keep some images this function may reclaim a lot more diskspace than the prune command. Try it!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.