Skip to content

single-cmd

Dockerfilesuspiciousno fixdefault: warndockerfile/hadolint

Reports each CMD after the first one in the same stage. A CMD after ONBUILD is not counted, and a new FROM starts the count again.

A container has one default command. When a stage lists several CMD instructions only the last one takes effect, and the earlier ones do nothing. They look like configuration that runs, so a reader edits the wrong line or believes a command runs that never does.

Delete all but the one you mean.

Reported
...
EXPOSE 80/tcp 443
...
CMD ["node", "server.js"]
...
ONBUILD CMD echo hi
...
dockerfile:
lint:
rules:
single-cmd: warn # off, warn (default), error

Enabled by the presets: dockerfile/hadolint.

Suppress one line with sudsy-disable-next-line single-cmd in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
hadolint DL4003 full