arriven / db1000n

MIT License
1.18k stars 208 forks source link

Disk usage is increasing with Docker containers #550

Closed MetaMmodern closed 2 years ago

MetaMmodern commented 2 years ago

Expected Behavior

Disk usage remains the same from update to update.

Actual Behavior

Disk usage is increasing. I guess this is happening because of some docker caching and layers in Dockerfile are not written correctly, so cache update is huge. Graph is for last 14 days of work. image

Steps to Reproduce the Problem

  1. run 2-3 instances of docker image using docker run -d --rm -it --pull always --network host ghcr.io/arriven/db1000n
  2. wait for several days, wait for updates I guess.
  3. check disk usage graphs.

Specifications

arriven commented 2 years ago

I don't think this is something I can fix on my end. This is just the way docker works (it keeps all the older versions of images even if you don't use those). You can clean the system up by using docker system prune periodically which should remove unused data. Depending on your setup you can opt into running that command periodically with some cron or run it on every deploy but usually running that once in a while is enough

I'm also working on a side project that will allow using single image to run and auto-update db1000n in different environments (including containers) but it's not ready yet

MetaMmodern commented 2 years ago

in different environments

@arriven what do you mean by this? Sounds cool, however AFAIK it's already possible to update db1000n without killing the container.

Forgot to say: thank you for the hint with prune) But maybe there is a way to minimize the layer sizes that changes on every code update. I will try to investigate it in a week or two.

arriven commented 2 years ago

AFAIR, the only layer that changes between versions is the one where the executable resides and I doubt it'll be possible to cache that

arriven commented 2 years ago

As for updates: docker tracks the container lifetime by existance of the process with PID 1. Any kind of version update requires to restart the process in order to update the code and the new process won't get the same id as old one. In order to get around that you need to use some external process as the controller and that's what I'm planning to do

MetaMmodern commented 2 years ago

Okay, I'll close this for how then. Thank you