How to Free Up Space on a GitLab Runner?

Hi everyone,

I’m running a self-hosted GitLab Runner, and recently, I’ve noticed that disk space is running low due to Docker images, volumes, and build caches accumulating over time. Running docker system df, I see:

scss

CopyEdit

TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          11        0         2.762GB   2.762GB (100%)
Containers      0         0         0B        0B
Local Volumes   119       0         5.051GB   5.051GB (100%)
Build Cache     613       0         58.57GB   58.57GB

As you can see, the build cache alone is taking up 58.57GB, and there are many unused Docker images and volumes.

so why Build Cache taking so much space and how to free some space also is it safe to delete local volume (what will happen if I delete local volume)

Hi,

Feel free to use docker system prune - this will delete dangling images and build cache. If you want to clean up all the images, there is a flag for that as well or docker image prune -a IIRC.

Volumes are basically your jobs’ cache. Feel free to delete those as well from time to time (I do it 1x a month). You can use docker volume prune -a.

Hope this helps! :slight_smile:

1 Like

so it is safe to delete build cache, local volumes without any issue?
can you explain why build cache take so much space

Yes, it’s safe. Just don’t use force, so you don’t mess up currently running stuff. I normally do this as part of maintenance, where I temporarily pause runners.

Well, it takes so much space because files you’re caching take up so much space. Take a closer look on how you’re generating and handling cache and you will have your answer. And GitLab never cleans this, you have to do it by yourself. So, if you have some super old cache from a branch from a year ago that is not used anymore anyways - it’s still there.

1 Like

docuum is the solution to clean up unused container images. See also Smart cache cleanup for Docker images & volumes (#27332) · Issues · GitLab.org / gitlab-runner · GitLab

1 Like