Cloud & DevOps · Question 14 · Hard
Cloud & DevOps question 14
In a Dockerfile for a Node.js app, why are package.json and package-lock.json usually copied, and dependencies installed, BEFORE the rest of the source code is copied?
- Docker requires dependency files to be copied first
- It makes the final image run faster at runtime
- It prevents the source code from being included in the image
- The dependency-install layer stays cached and is reused when only the source code changes, which speeds up rebuilds
Answer and explanation
Answer: D. The dependency-install layer stays cached and is reused when only the source code changes, which speeds up rebuilds
Explanation: Docker caches each instruction's layer and rebuilds from the first changed layer onward. If the dependency manifests are unchanged, the slow install step is reused from cache.
Previous: The file server.log contains these four lines: ERROR disk full INFO ok ERROR… · Next: Under the shared responsibility model for IaaS, who is responsible for…
Practise cloud & devops
Try a fresh set of cloud & devops questions with an explanation after every answer, free and without signing up: Cloud & DevOps practice. Or sit a full placement mock test.
More cloud & devops questions
- What is the difference between Continuous Delivery and Continuous Deployment?
- What does this shell pipeline print? Ignore any leading spaces.
- The file server.log contains these four lines: ERROR disk full INFO ok ERROR…
- Under the shared responsibility model for IaaS, who is responsible for…
- A developer uploads application code and the cloud provider runs it, managing…
- A bank keeps sensitive customer data in its own on-premises data centre but…
- Which Linux command prints the full path of the current working directory?
- What does Infrastructure as Code (IaC) mean?
- The ability of a cloud system to add resources automatically when demand rises…
- Which octal mode gives the permissions rw-r----- (owner read and write, group…
More technical & programming practice
GenAI Basics · Pseudo-code · C Programming · Java · Python · Data Structures · Algorithms · Object-Oriented Programming
LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge