Bird
0
0

Consider this Dockerfile snippet:

medium📝 Command Output Q4 of 15
Docker - Image Optimization
Consider this Dockerfile snippet:
FROM gcr.io/distroless/base
COPY app /app
CMD ["/app"]

If the application at /app crashes immediately after starting, what will be the container's behavior?
AThe container will restart automatically and provide a shell for debugging
BThe container will exit immediately with no interactive shell available
CThe container will stay running and print logs to the console
DThe container will open a shell prompt for manual intervention
Step-by-Step Solution
Solution:
  1. Step 1: Analyze distroless behavior

    Distroless images do not include shells or interactive tools, so no shell prompt is available.
  2. Step 2: Understand container lifecycle

    If the app crashes immediately, the container process exits, causing the container to stop.
  3. Final Answer:

    The container will exit immediately with no interactive shell available -> Option B
  4. Quick Check:

    Crash causes container exit; no shell in distroless [OK]
Quick Trick: Distroless containers exit on crash; no shell for debugging [OK]
Common Mistakes:
  • Assuming container restarts automatically without restart policy
  • Expecting an interactive shell to appear on crash
  • Believing logs will be printed automatically without explicit logging

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes