For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/dockerfile-not-using-json-in-cmd-and-entrypoint-arguments.md.
A documentation index is available at /llms.txt.
CMD and ENTRYPOINT should use the JSON (exec) form so commands are executed directly without invoking a shell. The shell/string form runs via /bin/sh -c which increases risk of command injection and can cause unpredictable argument parsing and improper signal forwarding (affecting graceful shutdown).
In Dockerfiles, check the CMD and ENTRYPOINT directives and require they be written as JSON arrays (exec form), for example, CMD ["executable", "arg1"] or ENTRYPOINT ["executable", "arg"]. If you need shell features, explicitly invoke a shell in the exec form (for example, ["sh","-c","..."]) so the use of a shell is intentional.