Description
Enforces that chained elements within Dockerfile instructions are placed on separate continuation lines using\. This improves readability and
produces cleaner diffs.
Applies to three instruction types:
- RUN — splits
&&/||chain boundaries AND splits multiple--mount=flags - LABEL — splits multiple
key=valuepairs - HEALTHCHECK CMD — splits
&&/||chain boundaries (shell form only)
Examples
Bad
Good
Configuration
Default (no config needed):Options
LABEL pair splitting and mount splitting always trigger when 2+ elements share a line (not affected by
min-commands).
Skipped Cases
The rule skips the following:- Exec form (
RUN ["cmd"]) — no shell to parse - Heredoc RUN (
RUN <<EOF) — chain splitting skipped; mount splitting still applies - Non-POSIX shell (PowerShell, cmd) — incompatible syntax
- Inline heredocs (
cat <<EOF && cmd) — reformatting would break heredoc boundaries - Single command — no chain to split
- Already formatted — elements already on separate lines
- Legacy LABEL format (
LABEL key value) — handled bybuildkit/LegacyKeyValueFormat - prefer-run-heredoc coordination — if
prefer-run-heredocis enabled and the command is a heredoc candidate, chain splitting is skipped to avoid conflicting fixes
Auto-fix
This rule provides a safe auto-fix. Continuation lines use tab indentation consistent with shell conventions (shfmt --bn):