Description
Exec-form CMD and ENTRYPOINT pass arguments directly to the executable. Shell-form instructions let the shell interpret the command.
Potential impact
A shell can change how arguments are interpreted or keep a stop signal from reaching the application.
Remediation
Write the executable and each argument as double-quoted strings in a JSON array. If the command relies on shell expansion or pipes, invoke a shell explicitly and test that the application receives its stop signal and shuts down cleanly.
Examples
[top] and [-b] lack the quotes required for JSON. With the quotes, CMD supplies -b to the top entrypoint. Use a Linux image that supports top -b.
Before
dockerfile
CMD [-b]
ENTRYPOINT [top]
After
dockerfile
CMD ["-b"]
ENTRYPOINT ["top"]