Skip to main content
Multiple CMD instructions should not be used in the same stage because only the last one will be used.

Description

If you have multiple CMD, 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:
Good:
You can have both a regular CMD and a separate CMD for HEALTHCHECK:

Auto-fix

The fix comments out duplicate CMD/ENTRYPOINT/HEALTHCHECK instructions, keeping only the last one in each stage.

Supersedes

Reference