Bird
0
0

How can you ensure that a sidecar container starts only after the main container is healthy and running?

hard📝 Application Q9 of 15
Docker - Production Patterns
How can you ensure that a sidecar container starts only after the main container is healthy and running?
AThere is no way to control start order in Docker Compose
BUse Docker Compose healthchecks and depends_on with condition: service_healthy
CUse a shell script inside sidecar to wait for main container logs
DStart sidecar container manually after main container
Step-by-Step Solution
Solution:
  1. Step 1: Understand Docker Compose start order controls

    Docker Compose supports depends_on with healthcheck conditions to control start order.
  2. Step 2: Evaluate options

    Manual start is error-prone; shell script waiting is workaround; There is no way to control start order in Docker Compose is incorrect.
  3. Final Answer:

    Use Docker Compose healthchecks and depends_on with condition: service_healthy -> Option B
  4. Quick Check:

    Start order = depends_on with healthcheck [OK]
Quick Trick: Use depends_on with healthcheck for start order [OK]
Common Mistakes:
  • Believing manual start is only way
  • Ignoring healthcheck feature
  • Thinking start order can't be controlled

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes