Skip to main content
Disallows multiple consecutive spaces within Dockerfile instructions.

Description

Multiple consecutive spaces within Dockerfile instructions are usually accidental and make the code harder to read. This rule flags any run of 2 or more consecutive space characters within instruction lines. The following are excluded:
  • Leading indentation: whitespace before the instruction keyword
  • Heredoc body lines: content between heredoc markers (semantically significant)
  • Comment lines: lines starting with #

Examples

Bad

Good

Auto-fix

This rule provides a safe auto-fix that replaces each run of multiple spaces with a single space:
Each contiguous run of extra spaces is replaced independently, so a line with multiple occurrences receives one edit per run.

Configuration

No custom configuration options. The rule is enabled by default with severity “style”.