Bird
0
0

Given this Dockerfile snippet:

medium📝 Command Output Q4 of 15
Docker - Image Optimization
Given this Dockerfile snippet:
FROM scratch
COPY app /app
CMD ["/app"]

What will happen when you build and run this container?
AThe container runs but crashes because /app is missing
BThe container fails because scratch has no shell to run commands
CThe container runs an Alpine Linux shell
DThe container runs the app binary copied to /app
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the Dockerfile commands

    The Dockerfile copies a binary named 'app' into the root filesystem at /app and sets it as the command to run.
  2. Step 2: Understand scratch behavior

    Scratch is empty but can run statically compiled binaries copied into it. Since /app exists, the container runs it.
  3. Final Answer:

    The container runs the app binary copied to /app -> Option D
  4. Quick Check:

    Scratch runs copied binaries directly [OK]
Quick Trick: Scratch runs only what you copy in [OK]
Common Mistakes:
  • Assuming scratch has a shell to run commands
  • Thinking /app is missing after COPY

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes