Multiple CMD instructions should not be used in the same stage because only the last one will be used.Documentation Index
Fetch the complete documentation index at: https://tally.wharflab.com/llms.txt
Use this file to discover all available pages before exploring further.
| Property | Value |
|---|---|
| Severity | Warning |
| Category | Best Practice |
| Default | Enabled |
| Auto-fix | Yes (--fix) |
Description
If you have multipleCMD, HEALTHCHECK, or ENTRYPOINT instructions in your
Dockerfile, only the last occurrence is used. An image can only ever have one
CMD, one HEALTHCHECK, and one ENTRYPOINT.
Examples
Bad:CMD and a separate CMD for HEALTHCHECK:
Auto-fix
The fix comments out duplicateCMD/ENTRYPOINT/HEALTHCHECK instructions,
keeping only the last one in each stage.
Supersedes
- hadolint/DL3012 (multiple
HEALTHCHECK) - hadolint/DL4003 (multiple
CMD) - hadolint/DL4004 (multiple
ENTRYPOINT)