Interview Prep/Docker/Resource Limits, Health & Reliability

How do you do graceful shutdown correctly?

IntermediateProductionResource Limits, Health & Reliability
Answer

App as PID 1 in exec form (or --init), handle SIGTERM: stop accepting new connections, finish in-flight requests, close DB pools, exit 0. Set --stop-timeout (or Compose stop_grace_period) longer than the drain time. Verify with time docker stop app: ~0s means handled, exactly 10s means it got SIGKILLed.

All Docker questions Roadmap: Docker & containers

More on Resource Limits, Health & Reliability