json-cmd-entrypoint
What it does
Section titled “What it does”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.
Why it matters
Section titled “Why it matters”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"].
Example
Section titled “Example”...WORKDIR $HOME...EXPOSE 80/tcp 443CMD node server.js...ENTRYPOINT /run.shONBUILD CMD echo hi...Configuration
Section titled “Configuration”dockerfile: lint: rules: json-cmd-entrypoint: warn # off, warn (default), errorEnabled by the presets: dockerfile/hadolint.
Suppress one line with sudsy-disable-next-line json-cmd-entrypoint in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| hadolint | DL3025 |
full |