What is the purpose of BuildKit’s cache mount (RUN –mount=type=cache) and how does it improve build performance?

Docker Fundamentals Hard

Docker Fundamentals — Hard

What is the purpose of BuildKit’s cache mount (RUN –mount=type=cache) and how does it improve build performance?

Key points

  • BuildKit cache mount reuses a persistent cache directory during a specific RUN instruction.
  • It helps maintain package manager caches (npm, pip, apt) across builds.
  • This feature significantly decreases dependency download time.
  • The cache is not included in the final image, keeping it lightweight.

Ready to go further?

Related questions