docker stop takes 10s and exits 137
Medium

Problem

Rolling deploys of payment-worker are crawling. Every restart sits for about 10 seconds on docker stop, and afterwards the container shows up as Exited (137) instead of a clean Exited (0). The web container next to it stops instantly. Something about how payment-worker shuts down is wrong — find it.

Initial setup

  • payment-worker — a queue worker, myworker:3.0.1, up 5 hours.
  • webnginx:alpine, up 5 hours, on 80 (the healthy comparison).

Example interaction

$ docker stop web
web
$ docker ps -a --filter name=web
CONTAINER ID   IMAGE          STATUS                     NAMES
ab12cd34ef56   nginx:alpine   Exited (0) 2 seconds ago   web

$ docker stop payment-worker     # hangs ~10s, then:
payment-worker
$ docker inspect -f '{{.State.ExitCode}}' payment-worker
137

Acceptance

You've solved it when:

  • You've established that payment-worker ignores SIGTERM: `docker
stop` waited the full stop-grace window and the daemon fell back to SIGKILL, so the container exited 137 (128 + 9) — not a clean 0 like web. This is an application signal-handling bug, not a daemon or disk fault.
  • You've stopped payment-worker (it is now Exited).

Constraints

  • Tools: docker CLI only.
  • The diagnosis must rest on the exit code (137 vs 0), read from
docker ps -a / docker inspect.

Follow-up

  1. Why does a SIGTERM-ignoring PID 1 produce 137 and not, say, 143
(128 + 15, SIGTERM)?
  1. docker stop vs docker kill here — which signal does each send first,
and why does kill get the same 137?
  1. What ENTRYPOINT form (exec vs shell) and what init (--init/tini)
would let the worker receive and honor SIGTERM?
Live session
Code
SavedNo commands yet