PSA: Discourse Docker Images Can Consume Large Amounts of Storage If You Don't Prune Docker

This weekend, while reviewing my Proxmox server, I noticed that my Discourse VM was using an excessive amount of storage. On a 64 GB provision, the VM was using 60% of that, or 38.4 GB (determined by running lvs on the Proxmox host).

This forum isn’t even a year old and seeing that kind of storage use is concerning, so I started to use the old cutdown method of finding out the source of this excessive storage usage. (I could have also used Diskover to determine this).

Iterating through the process a few times with sudo du -s /*, I discovered that the majority of my disk space was being consumed by /var/lib/docker:


Over 29 GB!

This VM is dedicated to Discourse, as such only Discourse could be responsible for this storage in Docker. Nonetheless, I ran sudo docker system df to confirm:

Bingo, I have a bunch of old Discourse Docker images causing this:

There’s more, but I think you get the idea.


Time to prune:

sudo docker system prune -a

WARNING: You should only run this command if you KNOW that your Discourse Docker container is currently running. If you run the above command and it is not in fact running, you will lose your Discourse forum. As such, you should make sure you always have current backups downloaded before running the above command.

Note: I first ran this without the -a (all) argument, which prunes all unused images, not just dangling ones. (This is why you see a less-than-expected amount of storage cleaned up in the screenshot below).

Hope this helps someone out.


Damn Torque, I have like 6 bookmarks in these forums. Boom. Now 7.

1 Like