Bird
0
0

You want to deploy a multi-container Docker app in production with these goals:

hard📝 Best Practice Q15 of 15
Docker - Production Patterns
You want to deploy a multi-container Docker app in production with these goals:
- Automatically restart containers on failure
- Monitor container health and alert if unhealthy
- Ensure containers start in correct order

Which combination of Docker Compose features best achieves this?
AUse restart: no, no healthcheck, and depends_on without conditions
BUse restart: always, healthcheck with retries, and depends_on with condition: service_healthy
CUse restart: on-failure, healthcheck without retries, and no depends_on
DUse restart: unless-stopped, healthcheck with interval 1h, and depends_on with condition: service_started
Step-by-Step Solution
Solution:
  1. Step 1: Choose restart policy for automatic recovery

    'restart: always' ensures containers restart on any stop, improving reliability.
  2. Step 2: Configure health checks with retries

    Health checks with retries detect unhealthy containers and allow alerting or action.
  3. Step 3: Use depends_on with service_healthy condition

    This ensures containers start only after dependencies are healthy, maintaining correct order.
  4. Final Answer:

    Use restart: always, healthcheck with retries, and depends_on with condition: service_healthy -> Option B
  5. Quick Check:

    Restart + healthcheck + depends_on healthy = production pattern [OK]
Quick Trick: Combine restart, healthcheck, and depends_on with health condition [OK]
Common Mistakes:
  • Skipping health checks or retries
  • Using depends_on without health condition
  • Choosing restart policies that don't restart on all failures

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes