Docker Cache Mount - uv as an Example

Docker’s cache mount (--mount=type=cache) looks simple on the surface, but it hides an important mental model that often trips people up—especially when mixing root vs non-root users, different home directories, or multi-stage builds. This post explains how cache mounts actually work, why they don’t share by default, and how to correctly share them, using uv cache as a concrete example. How Cache Mount Actually Works Consider this Dockerfile instruction: RUN --mount=type=cache,target=/root/.cache/uv \ uv sync When Docker executes this, it creates a named cache volume. The cache is keyed by: ...

December 15, 2025 · 3 min · sidecus