Skip to main content

DL4003: Multiple CMD instructions found

Warning Reliability

Why This Matters

Only the last CMD instruction takes effect. Multiple CMD instructions in a stage are almost always a mistake because the earlier ones are silently ignored. This leads to confusion when developers expect a specific CMD to run but Docker quietly uses only the last one. Keep a single CMD per stage.

How to Fix

Remove duplicate CMD instructions, keep only the final one

Before (incorrect)

CMD ["echo", "first"]
CMD ["echo", "second"]

After (correct)

CMD ["echo", "second"]

Rule Details

Rule Code
DL4003
Severity
Warning
Category
Reliability

Related Rules