Bird
0
0

You wrote this Dockerfile line:

medium📝 Troubleshoot Q14 of 15
Docker - Image Optimization
You wrote this Dockerfile line:
RUN --mount=type=cache,target=/root/.cache npm install

But the cache is not speeding up builds. What is the likely mistake?
AThe cache mount target directory is incorrect or not used by npm
BYou forgot to add <code>--cache</code> flag instead of <code>--mount</code>
CCache mounts only work with Python, not npm
DYou must run <code>docker build</code> with <code>--no-cache</code> option
Step-by-Step Solution
Solution:
  1. Step 1: Check cache mount target relevance

    Cache mount must target the directory where npm stores cache files, usually /root/.npm, not /root/.cache.
  2. Step 2: Understand npm cache usage

    If the target directory is wrong, npm won't use the cache, so builds stay slow.
  3. Final Answer:

    The cache mount target directory is incorrect or not used by npm -> Option A
  4. Quick Check:

    Correct cache target directory needed = C [OK]
Quick Trick: Match cache target to tool's actual cache folder [OK]
Common Mistakes:
  • Using wrong directory for cache mount target
  • Confusing --cache and --mount flags
  • Thinking cache mounts only work for some languages

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes