Bird
0
0

Which of the following Dockerfile RUN commands correctly cleans up the apt cache to minimize image size?

easy📝 Syntax Q3 of 15
Docker - Image Optimization
Which of the following Dockerfile RUN commands correctly cleans up the apt cache to minimize image size?
ARUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
BRUN apt-get update && apt-get install -y curl && apt-get clean
CRUN apt-get update && apt-get install -y curl
DRUN apt-get install -y curl && rm -rf /var/cache/apt
Step-by-Step Solution
Solution:
  1. Step 1: Update and install packages

    The command starts with 'apt-get update' and installs curl.
  2. Step 2: Remove apt cache files

    Removing '/var/lib/apt/lists/*' deletes the package lists, reducing image size.
  3. Final Answer:

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

    Cache removal after install reduces image size [OK]
Quick Trick: Remove apt lists after install to reduce image size [OK]
Common Mistakes:
  • Not removing apt cache files after installation
  • Using separate RUN commands causing extra layers
  • Only running apt-get clean without removing lists

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes