Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use exec form instead of shell form in docker files #3202

Closed
wants to merge 1 commit into from

Conversation

tpantelis
Copy link
Contributor

This is reported by Sonar:

"Using the shell form instead of the exec form for CMD and ENTRYPOINT instructions in Dockerfiles can lead to several issues. When you use the shell form, the executable runs as a child process to a shell, which does not pass OS signals. This can cause problems when trying to gracefully stop containers because the main process will not receive the signal intended to terminate it. Moreover, the exec form provides more control and predictability over the execution of the command. It does not invoke a command shell, which means it does not have the potential side effects of shell processing."

This is reported by Sonar:

"Using the shell form instead of the exec form for CMD and
ENTRYPOINT instructions in Dockerfiles can lead to several issues.
When you use the shell form, the executable runs as a child process
to a shell, which does not pass OS signals. This can cause problems
when trying to gracefully stop containers because the main process
will not receive the signal intended to terminate it. Moreover, the
exec form provides more control and predictability over the execution
of the command. It does not invoke a command shell, which means it
does not have the potential side effects of shell processing."

Signed-off-by: Tom Pantelis <[email protected]>
@submariner-bot
Copy link
Contributor

🤖 Created branch: z_pr3202/tpantelis/docker_exec_form
🚀 Full E2E won't run until the "ready-to-test" label is applied. I will add it automatically once the PR has 2 approvals, or you can add it manually.

@skitt
Copy link
Member

skitt commented Oct 30, 2024

This is a false positive — the entrypoints are all shell scripts, so running them using a shell or directly ends up doing the same thing, with the same number of processes (unless sh isn’t bash; but that’s not the case in our container images). The shell scripts handle signals themselves (that’s what the trap lines set up).

@tpantelis
Copy link
Contributor Author

This is a false positive — the entrypoints are all shell scripts, so running them using a shell or directly ends up doing the same thing, with the same number of processes (unless sh isn’t bash; but that’s not the case in our container images). The shell scripts handle signals themselves (that’s what the trap lines set up).

Ok - I'll mark the Sonar issues as false positives.

@tpantelis tpantelis closed this Oct 30, 2024
@submariner-bot
Copy link
Contributor

🤖 Closed branches: [z_pr3202/tpantelis/docker_exec_form]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants