Challenge - 5 Problems
RUN Instruction Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this Dockerfile RUN command?
Consider this Dockerfile snippet:
What will be the output when building this Docker image?
FROM alpine RUN echo Hello World
What will be the output when building this Docker image?
Docker
FROM alpine
RUN echo Hello WorldAttempts:
2 left
💡 Hint
RUN commands execute during image build and their output appears in build logs.
✗ Incorrect
The RUN instruction executes commands during the image build. The output of 'echo Hello World' appears in the build logs but does not run when the container starts.
🧠 Conceptual
intermediate1:30remaining
What does the RUN instruction do in a Dockerfile?
Choose the best description of the RUN instruction in a Dockerfile.
Attempts:
2 left
💡 Hint
RUN commands happen once during build, not at container start.
✗ Incorrect
RUN executes commands during image build and creates a new layer with the changes. It does not run when the container starts.
❓ Troubleshoot
advanced2:30remaining
Why does this RUN command fail in Dockerfile?
Given this Dockerfile snippet:
What is the cause of the failure?
FROM ubuntu RUN apt-get update && apt-get install -y python3 pip
What is the cause of the failure?
Docker
FROM ubuntu
RUN apt-get update && apt-get install -y python3 pipAttempts:
2 left
💡 Hint
Check package names carefully when installing with apt-get.
✗ Incorrect
The package 'pip' does not exist in Ubuntu repositories; the correct package is 'python3-pip'. The RUN command syntax and apt-get usage are correct.
🔀 Workflow
advanced2:00remaining
How to combine multiple commands in a single RUN instruction?
You want to update package lists and install curl in one RUN instruction. Which option correctly does this?
Attempts:
2 left
💡 Hint
Use command chaining to run commands sequentially only if the first succeeds.
✗ Incorrect
Using '&&' chains commands so the second runs only if the first succeeds. ';' runs commands sequentially regardless of success, '||' runs second only if first fails, '&' runs in background which is invalid here.
✅ Best Practice
expert3:00remaining
What is the best practice to reduce Docker image layers when using RUN?
You want to install packages and clean cache in one RUN instruction to keep image size small. Which option follows best practice?
Attempts:
2 left
💡 Hint
Combine commands with && to create a single layer and clean cache in the same RUN.
✗ Incorrect
Combining commands with '&&' in one RUN instruction creates a single image layer. Cleaning cache in the same RUN prevents cache files from being saved in a separate layer, reducing image size.