Bird
0
0

Given this Dockerfile snippet:

medium📝 Command Output Q4 of 15
Docker - in CI/CD
Given this Dockerfile snippet:
FROM python:3.12-slim
RUN pip install flask
COPY app.py /app/
RUN python /app/app.py

Which layer will be rebuilt if only app.py changes during CI build?
AThe FROM python:3.12-slim base image layer
BThe RUN pip install flask layer
CAll layers will be rebuilt
DThe last RUN layer running the app.py script
Step-by-Step Solution
Solution:
  1. Step 1: Understand layer caching and COPY instruction

    Changing app.py affects the COPY instruction and any layers after it.
  2. Step 2: Identify which RUN layer depends on app.py

    The last RUN runs app.py, so it must be rebuilt; earlier layers remain cached.
  3. Final Answer:

    The last RUN layer running the app.py script -> Option D
  4. Quick Check:

    Changed file affects subsequent layers only [OK]
Quick Trick: Only layers after changed files rebuild in Docker cache [OK]
Common Mistakes:
  • Assuming all layers rebuild on any change
  • Thinking base image layer rebuilds
  • Confusing order of layers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes