Recall & Review
beginner
What does the RUN instruction do in a Dockerfile?
The RUN instruction executes commands in a new layer on top of the current image and commits the results. It is used to install software or make changes during image build.
Click to reveal answer
beginner
How do you write a RUN instruction to update package lists on a Debian-based image?
RUN apt-get update
Click to reveal answer
intermediate
What is the difference between using RUN with shell form and exec form?
Shell form: RUN command runs in a shell (e.g., /bin/sh -c), allowing shell features like variable expansion. Exec form: RUN ["executable", "param1", "param2"] runs directly without a shell.
Click to reveal answer
intermediate
Why should you combine multiple commands in a single RUN instruction?
Combining commands reduces the number of image layers, making the image smaller and more efficient.
Click to reveal answer
beginner
Example: How to install curl and clean cache in one RUN instruction?
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
Click to reveal answer
What does the RUN instruction do in a Dockerfile?
✗ Incorrect
RUN executes commands during the image build process and creates a new layer with the changes.
Which RUN syntax runs commands without a shell?
✗ Incorrect
The exec form RUN ["executable", "param1"] runs commands directly without a shell.
Why combine multiple commands in one RUN instruction?
✗ Incorrect
Combining commands reduces the number of layers, making the image smaller.
What happens if you run 'RUN apt-get update' alone in a Dockerfile?
✗ Incorrect
RUN commands execute during image build, so apt-get update updates package lists then.
Which command cleans up apt cache after installing packages?
✗ Incorrect
Removing /var/lib/apt/lists/* cleans apt cache to reduce image size.
Explain how the RUN instruction works in a Dockerfile and why it is important.
Think about when the commands run and how they affect the image.
You got /3 concepts.
Describe best practices for writing RUN instructions to keep Docker images small.
Focus on how to optimize image size and layers.
You got /3 concepts.