How to set up a systemd system service (with User=
) that runs a caddy executable without conmon and the OCI runtime in the rootless podman network namespace?
#24626
Replies: 2 comments
-
I think using I have not looked deeply at the cgroup stuff but if the move out of the unit cgroup is the issue then maybe registry.NoMoveProcess option in the code that can be set on a per podman command basis. I think we can set it for podman unshare. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the input and the tip about I started drafting a PR (it's work-in-progress): Currently it makes use of
but using |
Beta Was this translation helpful? Give feedback.
-
How to set up a systemd system service (with systemd directive
User=
) that runs a caddy executable in the rootless podman network namespace? (conmon and the OCI runtime should not be used)I would like the caddy process to serve as an HTTP reverse proxy for podman containers running in a custom network. Rootless Podman with Pasta is used for the containers in the custom network.
First I tried with
ExecStart=podman unshare --rootless-netns /usr/local/bin/caddy ...
. It worked fine but when I stopped the service with the commandsystemctl stop caddy.service
the caddy process kept running.I think systemd didn't kill the process because caddy is not a direct child process of systemd (or some similar explanation related to cgroups).
Anyway, I then tried using
nsenter
instead. Here are the relevant parts of the file caddy.serviceThat worked better. The command
systemctl stop caddy.service
stopped the caddy process.These two lines were added to let the service run with extra restrictions
This line
was added to be able to use the environment variable
$XDG_RUNTIME_DIR
Any suggestions of how to improve this hackish solution that makes use of
nsenter
?(The solution currently has a race condition as it does not make use of file locking and the file
$XDG_RUNTIME_DIR/containers/networks/rootless-netns/ref-count
)Maybe Podman could add support for this use case by
introducing a new command-line option
--exec
to podman unshare?
A sketch: (This syntax does not currently exist)
A tricky problem is how to decrease
$XDG_RUNTIME_DIR/containers/networks/rootless-netns/ref-count
when the service stops. Maybe an additional command would be needed
A sketch: (This syntax does not currently exist)
Note, this discussion thread has some similarities to
but here
ExecStart=
does not execute podman, conmon, or the OCI runtime (crun, runc).Beta Was this translation helpful? Give feedback.
All reactions