Skip to content

.tip

· one of the small things

Exec-form CMD so SIGTERM reaches your process

CMD node server.js runs under /bin/sh -c, which makes the shell PID 1, and the shell doesn't forward signals. On docker stop the app never gets SIGTERM, waits out the ten second grace period, and is killed mid-request.

CMD ["node", "server.js"]

The JSON form execs the process directly, so your shutdown handler runs and in-flight requests finish. If the app spawns children and leaves zombies behind, add --init to docker run, or init: true in Compose.

dockeroperations