Skip to content

json-cmd-entrypoint

Dockerfilesuspiciousno fixdefault: warndockerfile/hadolint

Reports a CMD, ENTRYPOINT or HEALTHCHECK CMD in shell form. That is CMD node server.js instead of the JSON array form CMD ["node", "server.js"]. The same instruction after ONBUILD is not reported.

The shell form runs the command as /bin/sh -c "...", so the shell, not your program, is the main process of the container. docker stop sends SIGTERM to that shell, which usually does not pass it on; after the timeout (10 seconds by default) Docker kills the container with SIGKILL, and the program gets no chance to shut down cleanly. With an ENTRYPOINT in shell form, the arguments of CMD and of docker run are ignored as well.

The JSON form starts the program directly. If you need a shell, write ["sh", "-c", "exec node server.js"].

Reported
...
WORKDIR $HOME
...
EXPOSE 80/tcp 443
CMD node server.js
...
ENTRYPOINT /run.sh
ONBUILD CMD echo hi
...
dockerfile:
lint:
rules:
json-cmd-entrypoint: warn # off, warn (default), error

Enabled by the presets: dockerfile/hadolint.

Suppress one line with sudsy-disable-next-line json-cmd-entrypoint 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 DL3025 full