-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
podman does not detect systemd entrypoints when prefixed with /bin/sh #13324
Comments
That (i.e., |
@vrothberg the container works though and I haven't observed systemd actually complaining |
Indeed systemd is PID 1 in this case. There must be some knowledge gap on my end. I'll investigate a bit further. |
It seems this is an optimization by some shells with the last command not being fork'd but exec'd. I do not know if |
you could override the |
I concur. We cannot/should not rely on shells to behave like that consistently. |
Certainly, I stated that in the bugreport. But I would still consider it a great quality of life improvement if podman would do the right thing in this case, as I guess that most shells will behave so that systemd would still work. |
I can go back to the original version of this patch which looked specifically for ["/bin/sh", "-c", "PATHTO/systemd"] since this is almost certainly the case where podman added the /bin/sh -c. sh -c "command" I would think always execs the command within the same PID as the shell. |
I would definitely be in favor of that.
Unfortunately this is not guaranteed by the POSIX standard. Most shells do that, but we can't really rely on that. |
Fixes: containers#13324 Signed-off-by: Daniel J Walsh <[email protected]>
Thanks for fixing this @rhatdan! |
Fixes: containers#13324 Signed-off-by: Daniel J Walsh <[email protected]>
The if condition is required due to containers/podman#13324
Hello, thank you all for the issue report and the fix. If I run a container with an entrypoint such as the following
the detection does not work, and
however that naturally fails to pass the Is there possibly an elegant solution to my use case with the current "detection" code which does not involve manually passing The reason I am not executing systemd directly is wanting a shell script as an entrypoint which can make use of environment variables and do some basic system configuration before |
@tacerus, I don't see a way. How could podman know what Note that systemd really needs to be the PID 1 inside the container. |
Thanks for your input. Given it's a shell script, which runs exec at the end, the PID 1 becomes systemd - the shell script is only doing temporary configuration and then disappears. It works fine with
just that |
I think at one time we were doing something like that and it was complained about, basically stating that they did not want to run in systemd mode. I tend to agree that systemd in entrypoint or command should put us into systemd mode. You could also call your entrypoint script systemd, which would trigger the behaviour you want, I believe. ENTRYPOINT ["/usr/local/sbin/systemd"] |
I see - well, maybe it could be considered again in the future - but I get there might be other use cases. Thank you so much! That "hack" with calling my entrypoint script |
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
/kind feature
Description
Podman automatically detects whether a container is launching systemd as it's
CMD
orENTRYPOINT
. Unfortunately this logic only works when systemd is added asCMD ["/usr/lib/systemd/systemd"]
. If you add it viaCMD /usr/lib/systemd/systemd
then podman will fail to launch it without the--systemd=always
flag.Steps to reproduce the issue:
Dockerfile
:build it via
buildah bud --layers .
and launch the container viapodman run --rm -it $HASH
, which should workChange the
Dockerfile
to:buildah bud --layers .
and launch the container viapodman run --rm -it $HASH
which will fail with:but if you add the
--systemd=always
flag, then the container works.The issue here is that in the 2nd
Dockerfile
results in the following command that can be found via `podman inspect:whereas the first one results in:
But podman only recognizes the latter as a systemd container.
Additional information you deem important (e.g. issue happens only occasionally):
Output of
podman version
:Output of
podman info --debug
:Package info (e.g. output of
rpm -q podman
orapt list podman
):build from main and
podman-3.4.4-1.fc35.x86_64
Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)
Yes
The text was updated successfully, but these errors were encountered: