Challenge - 5 Problems
Cache Mount Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of Docker build with cache mount
What will be the output of the following Docker build command snippet when using cache mount for pip packages?
Docker
RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt
Attempts:
2 left
💡 Hint
Think about what the cache mount does for package managers during builds.
✗ Incorrect
The --mount=type=cache option tells Docker to save and reuse the pip cache directory between builds. This speeds up package installation by avoiding repeated downloads.
🧠 Conceptual
intermediate1:30remaining
Purpose of cache mounts in Docker builds
Why are cache mounts used in Docker builds?
Attempts:
2 left
💡 Hint
Think about what slows down builds and how cache helps.
✗ Incorrect
Cache mounts allow Docker to save data like package caches between builds, so repeated operations don't redo work, making builds faster.
❓ Troubleshoot
advanced2:00remaining
Troubleshooting cache mount syntax error
You run this Dockerfile line but get a syntax error:
RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt. What is the likely cause?Attempts:
2 left
💡 Hint
Check Dockerfile version and syntax requirements for cache mounts.
✗ Incorrect
Cache mounts require Dockerfile syntax version 1.4 or higher, specified by # syntax=docker/dockerfile:1.4 at the top of the Dockerfile.
🔀 Workflow
advanced2:30remaining
Optimizing Docker build with cache mounts
Which Dockerfile snippet best uses cache mounts to speed up npm package installation during build?
Attempts:
2 left
💡 Hint
Consider the correct cache directory for npm and mount type.
✗ Incorrect
npm stores cache in /root/.npm. Using type=cache mount on this directory speeds up installs by caching downloaded packages.
✅ Best Practice
expert3:00remaining
Best practice for cache mount usage in multi-stage builds
In a multi-stage Docker build, where should you place cache mounts for package managers to maximize build speed and minimize final image size?
Attempts:
2 left
💡 Hint
Think about where package installation happens and what ends up in the final image.
✗ Incorrect
Cache mounts should be used in the build stage to speed up package installs. The final stage should be clean without cache data to keep image size small.