Recall & Review
beginner
What is the purpose of combining RUN commands in a Dockerfile?
Combining RUN commands helps reduce the number of image layers, making the Docker image smaller and more efficient.
Click to reveal answer
beginner
How do you combine multiple RUN commands in a Dockerfile?
You combine them using shell operators like
&& to run commands sequentially in one RUN instruction.Click to reveal answer
beginner
Example: What does this Dockerfile line do?<br>
RUN apt-get update && apt-get install -y curl
It updates the package list and then installs curl in one layer, reducing image size and build time.
Click to reveal answer
intermediate
Why should you use
&& instead of ; when combining RUN commands?Using
&& ensures the next command runs only if the previous one succeeds, preventing errors from being ignored.Click to reveal answer
intermediate
What is a downside of combining too many commands in one RUN instruction?
If one command fails, the whole RUN fails, and debugging can be harder because all commands are in one layer.
Click to reveal answer
What does combining RUN commands with
&& in a Dockerfile help achieve?✗ Incorrect
Combining RUN commands with && runs them sequentially in one layer, reducing image layers and size.
Which operator ensures the next command runs only if the previous command succeeds?
✗ Incorrect
The && operator runs the next command only if the previous command succeeds.
What happens if you use multiple RUN commands separately instead of combining them?
✗ Incorrect
Each RUN command creates a new image layer, increasing image size.
Which is a good practice when combining RUN commands?
✗ Incorrect
Using && ensures commands run only if previous succeed, which is good practice.
What is a potential downside of combining many commands in one RUN?
✗ Incorrect
If one command fails in a combined RUN, it can be harder to find the error.
Explain why and how you would combine RUN commands in a Dockerfile.
Think about how Docker images are built in layers.
You got /3 concepts.
Describe the benefits and drawbacks of combining multiple commands in a single RUN instruction.
Consider both image optimization and troubleshooting.
You got /4 concepts.