CS FundamentalsHardProduct-company MCQ pattern
A Dockerfile reads: FROM python:3.12 COPY . /app RUN pip install -r /app/requirements.txt Every small code edit makes the build reinstall all dependencies. What is the best fix?
- A. Add --no-cache to every build
- B. Copy requirements.txt and run pip install before copying the rest of the code
- C. Move RUN pip install above FROM
- D. Use a larger base image
Correct answer: B. Copy requirements.txt and run pip install before copying the rest of the code
Docker caches layers in order and invalidates every layer after the first changed one. COPY . changes on any code edit, so the pip layer reruns. Copying only requirements.txt first, then installing, then COPY . keeps the dependency layer cached until requirements change. --no-cache makes it worse.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- How many of the following statements about Kubernetes are correct? 1. A Pod is the smallest deployable unit and can never hold more than…
- Match each project situation with the most suitable SDLC model. P. Requirements fixed and well understood, short project Q. Large…
- How many of the following statements about Scrum are correct? 1. A sprint may be extended by a few days when the sprint goal has not yet…
- In top-down integration testing, the top-level module is ready but the lower-level modules it calls are not. What must the testers write…
- Mutation testing creates 50 mutants of a program. 5 of them are equivalent mutants (they behave identically to the original). The test…
- Before release, 120 defects are found in system testing and 30 in user acceptance testing. After release, customers report 50 more. What…