Bird
0
0

Which Dockerfile instruction helps reduce image size by cleaning up after package installation?

easy📝 Syntax Q3 of 15
Docker - Image Optimization
Which Dockerfile instruction helps reduce image size by cleaning up after package installation?
ACMD ["python", "app.py"]
BRUN apt-get update && apt-get install -y package && rm -rf /var/lib/apt/lists/*
CEXPOSE 80
DCOPY . /app
Step-by-Step Solution
Solution:
  1. Step 1: Identify cleanup commands in RUN instruction

    The command removes package cache files after installation to reduce image size.
  2. Step 2: Recognize other instructions do not clean up

    COPY, EXPOSE, and CMD do not affect image size cleanup.
  3. Final Answer:

    RUN apt-get update && apt-get install -y package && rm -rf /var/lib/apt/lists/* -> Option B
  4. Quick Check:

    Cleanup after install = RUN with rm command [OK]
Quick Trick: Clean package cache in same RUN to reduce image size [OK]
Common Mistakes:
  • Not cleaning cache after package install
  • Using COPY or CMD for cleanup

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes