Docker and CI/CD · Middle · Question 2 of 75

Why does this Dockerfile reinstall all dependencies on every code change? ``dockerfile COPY . . RUN npm ci

Explanation

Cache invalidation cascades: once a layer changes, every later layer is rebuilt. Copy package.json and the lockfile, run npm ci, then copy the rest.

Further reading

Problem with a question

Docker and CI/CD · Middle · question 2

Test yourself

Take the Docker and CI/CD · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz