Interview Prep/Docker/Dockerfile Instructions & Builds

What are BuildKit cache mounts?

IntermediateConceptDockerfile Instructions & Builds
Answer

RUN --mount=type=cache,target=... gives a persistent directory across builds that is not part of any layer. Great for package manager caches.

RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt

The cache is local to the builder; in CI you need cache export or a persistent builder.

All Docker questions Roadmap: Docker & containers

More on Dockerfile Instructions & Builds