| Property | Value |
|---|---|
| Severity | Info |
| Category | Best-practice |
| Default | Enabled |
| Auto-fix | Yes — safe for missing STOPSIGNAL, suggestion (requires --fix-unsafe) for replacing an existing value |
Description
When a container runsnginx or openresty as PID 1, the container runtime’s
default stop signal (SIGTERM, signal 15) triggers nginx’s fast shutdown:
active connections are dropped immediately. The correct signal for a
container stop is SIGQUIT, which triggers nginx’s graceful shutdown:
workers finish in-flight requests, then exit.
This rule fires when:
- the stage’s effective PID 1 is
nginxoropenresty(bare name or absolute path such as/usr/sbin/nginx), and STOPSIGNALis either missing or set to a signal that normalizes to anything other thanSIGQUIT.
When the rule does not fire
- Shell-form
ENTRYPOINTorCMD— the shell becomes PID 1, not nginx, so the signal mapping is unreliable. - Opaque exec-form shell wrappers (
["sh", "-c", ...],["bash", "-c", ...]) — the first token issh/bash, not nginx. - Non-nginx executables (postgres, php-fpm, systemd, etc.) — other daemon-specific rules handle those.
nginx-debugand similar variants — the basename must be exactlynginxoropenresty.- Windows stages —
STOPSIGNALhas no effect on Windows containers. - Environment variable signals (e.g.
STOPSIGNAL $MY_SIGNAL) — the value cannot be determined statically.
References
Examples
Bad
Good
Auto-fix
The rule provides two fix modes depending on the violation: Missing STOPSIGNAL — insertsSTOPSIGNAL SIGQUIT before the
ENTRYPOINT/CMD instruction. FixSafe: applied with plain --fix.
SIGQUIT.
FixSuggestion: requires --fix-unsafe because the user explicitly chose
a signal and SIGTERM is still a valid (if not preferred) shutdown signal.
Cross-rule interactions
- tally/prefer-canonical-stopsignal: Normalizes tokens such as
QUITor3intoSIGQUIT. This rule checks the normalized value, so those spellings are accepted as correct and only the canonical rule fires. - tally/no-ungraceful-stopsignal: On an nginx stage with
SIGKILLorSIGSTOP, both rules want to replace the signal. The fixer’s category-based conflict resolution rankscorrectnessabovebest-practice, sono-ungraceful-stopsignalwins first and replaces withSIGTERM. A subsequent--fix-unsafepass then promotesSIGTERMtoSIGQUITvia this rule’s wrong-signal fix.