Interview Prep/Docker/Volumes, storage and data

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.

All Docker questions Roadmap: Docker & containers

More on Volumes, storage and data