Persist a cache for CI jobs across runs on a self-hosted runner.
IntermediateScenarioVolumes, storage and data
Answer
Situation read → Repeated dependency downloads.
What I'd do → Mount a named volume for ~/.cache/~/.m2 into job containers, or rely on BuildKit cache mounts on a persistent builder. Add size limits via builder GC (keepStorage) and key by lockfile hash when using external caches.
Why → Persistent runners make local caches effective; ephemeral ones need remote caches.
Interview tip → Beware cache poisoning between untrusted PR builds; isolate caches per trust level.
More on Volumes, storage and data
A Postgres container was removed and the data is gone. How should it have been run?BeginnerBind mount or named volume for local development of a Node app?BeginnerHow do you back up a named volume?IntermediateTwo containers must share files. What are your options?BeginnerA container needs a writable temp area but the root filesystem is read-only.IntermediateMoving a database volume from one Docker host to another.Intermediate