| Property | Value |
|---|---|
| Severity | Style |
| Category | Style |
| Default | Enabled |
| Auto-fix | Yes (safe) |
Description
Dockerfiles should end each output stage with runtime-configuration instructions in a canonical order: STOPSIGNAL, HEALTHCHECK, ENTRYPOINT, CMD. These epilogue instructions configure how the container runs rather than how the image is built, and placing them at the end of the stage makes the Dockerfile easier to read and maintain. This rule checks two conditions for each applicable stage:- Position: All epilogue instructions must appear at the end of the stage (no build instructions like RUN, COPY, ENV after them)
- Order: Among the epilogue instructions, they must appear in canonical order
COPY --from, FROM, or RUN --mount=from). Intermediate
builder stages are skipped since they typically don’t use epilogue instructions.
Examples
Bad
Good
Multi-stage (builder skipped)
Auto-fix
This rule provides a safe auto-fix that moves epilogue instructions to the end of the stage in canonical order:- Removes each epilogue instruction from its current position
- Inserts all epilogue instructions at the end of the stage in canonical order
- Preserves preceding comments and continuation lines
MultipleInstructionsDisallowed rule handles duplicate removal.
Cross-rule interactions
| Rule | Interaction |
|---|---|
tally/newline-between-instructions | Runs after this rule’s fix (priority 200 vs 175). Normalizes blank lines between the reordered epilogue instructions. The combined result is stable. |
buildkit/MultipleInstructionsDisallowed | Runs before (sync fix). Removes duplicate CMD/ENTRYPOINT/HEALTHCHECK. If duplicates remain (rule disabled), this rule skips the fix for safety. |