Interview Prep/Docker/Image design and Dockerfile decisions

Your app ignores `docker stop` and takes exactly 10 seconds to die. Why and what do you change?

IntermediateScenarioImage design and Dockerfile decisions
Answer

Situation read → The process is not receiving or handling SIGTERM, so Docker sends SIGKILL after the grace period.

What I'd do →

  1. Check docker inspect -f '{{.Config.Entrypoint}} {{.Config.Cmd}}' c for shell form (/bin/sh -c ...).
  2. Switch to exec form or add exec in the wrapper script.
  3. If the app does not reap zombies or handle signals, run with --init (tini).
  4. Handle SIGTERM in the app (graceful shutdown) and optionally set STOPSIGNAL and --stop-timeout.

Why → PID 1 in a container gets no default signal handlers from the kernel; it must install its own.

Interview tip → Mention docker run --init as the zero-code fix.

All Docker questions Roadmap: Docker & containers

More on Image design and Dockerfile decisions