Cache in self-managed Runner

I’m not getting any cache hits when jobs run on the docker Runner that I have locally (builds are passing fine, just no cache hits). This is my gitlab-runner.yml

concurrent = 4
check_interval = 0

[[runners]]
  name = "<elided>"
  url = "https://gitlab.com/"
  token = "<elided>"
  executor = "docker"
  [runners.docker]
    tls_verify = false
    image = "fommil/docker-openjdk-sbt:latest"
    privileged = false
    disable_cache = false
    cache_dir = "/var/lib/gitlab-runner/"
    volumes = ["/var/lib/gitlab-runner/"]
    shm_size = 0
  [runners.cache]

which is following https://docs.gitlab.com/runner/configuration/advanced-configuration.html as best I can

Even when the build says

Creating cache default...
project/.sbt: found 2112 matching files            
Created cache
Job succeeded

I’m not getting any files appearing in /var/lib/gitlab-runner

what am I doing wrong?

oh, could it be that this is a different kind of cache? Maybe I need one of these https://docs.gitlab.com/runner/install/autoscaling.html#install-the-cache-server

Assuming you want to see files locally in /var/lib/gitlab-runner, you can mount the volume as per Docker volume syntax:

volumes = ["/var/lib/gitlab-runner:/var/lib/gitlab-runner:rw"]

This works particularly well for package caches. :slight_smile: