Recall & Review
beginner
What is a layer in a Docker image?
A layer is a set of filesystem changes created by each command in a Dockerfile. Layers stack to form the final image.
Click to reveal answer
beginner
Why should you minimize layers in a Docker image?
Fewer layers mean smaller image size, faster builds, and quicker downloads, making containers more efficient.
Click to reveal answer
intermediate
How can you combine commands to reduce layers in a Dockerfile?
Use the shell's '&&' to join commands in a single RUN instruction, so they create only one layer.
Click to reveal answer
intermediate
What is the effect of using multiple RUN commands versus a single RUN command with combined commands?
Multiple RUN commands create multiple layers; combining commands in one RUN creates a single layer, reducing total layers.
Click to reveal answer
beginner
Give an example of minimizing layers by combining commands in a Dockerfile.
Instead of:
RUN apt-get update
RUN apt-get install -y curl
Use:
RUN apt-get update && apt-get install -y curl
Click to reveal answer
What happens when you use multiple RUN commands in a Dockerfile?
✗ Incorrect
Each RUN command creates a new layer in the Docker image.
Which method helps reduce the number of layers in a Docker image?
✗ Incorrect
Combining commands with '&&' in one RUN instruction creates only one layer.
Why is minimizing layers important in Docker images?
✗ Incorrect
Fewer layers reduce image size and improve build and download speed.
Which Dockerfile instruction creates a new layer?
✗ Incorrect
RUN creates a new layer; ENV, LABEL, and ARG do not create layers.
What is a simple way to clean up temporary files in the same layer to minimize layers?
✗ Incorrect
Cleaning files in the same RUN command keeps the layer small and avoids extra layers.
Explain how minimizing layers in a Dockerfile improves container efficiency.
Think about how layers affect image size and build speed.
You got /4 concepts.
Describe a practical way to reduce layers when installing software in a Dockerfile.
Focus on how to write RUN commands efficiently.
You got /3 concepts.