| Property | Value |
|---|---|
| Severity | Style |
| Category | Style |
| Default | Enabled |
| Auto-fix | Yes (safe) |
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
| Option | Type | Default | Description |
|---|---|---|---|
min-commands | integer | 2 | Minimum chained commands to trigger chain splitting (>= 2). Applies to RUN and HEALTHCHECK CMD. |
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):