Bird
0
0

Find the mistake in this Dockerfile that causes a larger image size:

medium📝 Troubleshoot Q7 of 15
Docker - Image Optimization
Find the mistake in this Dockerfile that causes a larger image size:
FROM ubuntu
RUN apt-get update
RUN apt-get install -y curl
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
Aapt-get clean command is incorrect
BMissing --no-cache flag
CBase image should be Alpine
Dapt-get update and install should be in one RUN command
Step-by-Step Solution
Solution:
  1. Step 1: Understand layer creation

    Each RUN creates a layer; separate update and install create extra layers.
  2. Step 2: Combine commands to reduce layers

    Combining update and install in one RUN reduces image size.
  3. Final Answer:

    Separate RUN commands for update and install increase image size. -> Option D
  4. Quick Check:

    Combine commands to reduce layers [OK]
Quick Trick: Combine update and install in one RUN to reduce layers [OK]
Common Mistakes:
  • Ignoring layer count
  • Wrong clean syntax
  • Assuming base image change fixes this

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes