| Property | Value |
|---|---|
| Severity | Warning |
| Category | Correctness |
| Default | Enabled |
| Auto-fix | Yes |
Description
Docker image labels are a key/value map. If the same key is written more than once in one build stage, Docker keeps the last value and the earlier value becomes review noise. This rule reports duplicate keys within the same stage. It does not compare labels across stages, because intermediate stages often describe different build artifacts and only the selected final stage’s labels are published in the resulting image. Dynamic keys such asLABEL "$PREFIX.name"=value are skipped by duplicate
detection because their final key cannot be proven statically.
Auto-fix
For redundant standaloneLABEL instructions, the preferred fix comments out
the earlier instruction. A second fix option removes it. The fix targets earlier
labels because Docker keeps the last value for a key.
When the duplicate key appears inside a multi-pair LABEL instruction, Tally
still reports the duplicate but does not rewrite the instruction unless the
obsolete pair can be removed without dropping unrelated labels.
Examples
Bad
Good
Configuration
No custom configuration options. The rule is enabled by default with severitywarning.