[Solved] How to Auto-starting rootless pods using systemd

Latest response

Hello Community,
I'm new to the podman container ecosystem. So far I've managed to create and run rootless pods and containers with shared volumes between them using an unprivileged user account.

When the system gets restarted I have to login and start the pod manually in order get my service up and running. That's not very convenient so I would like to have systemd to take care of this job and studied [8.5. Auto-starting pods using systemd](8.5. Auto-starting pods using systemd) in the Building, running, and managing containers guide.

The solution provided in documentation only starts the service when the user logs in and stops it when the user logs out. But I would like to have the pod running regardless of the users login status.

Copying the auto-generated service units to /etc/systemd/system/ and trying to start the pod running sudo systemctl start pod-examplepod.service fails because systemd isn't able to find the infra-container which belongs the pod. The following snippet shows an example of an error message:

Jan 25 13:54:40 podhost-r8-1.lan systemd[1]: Starting Podman pod-kanboardpod.service...
-- Subject: Unit pod-kanboardpod.service has begun start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
-- 
-- Unit pod-kanboardpod.service has begun starting up.
Jan 25 13:54:40 podhost-r8-1.lan podman[63084]: Error: no container with name or ID 62cdd29105a4-infra found: no such container
Jan 25 13:54:40 podhost-r8-1.lan systemd[1]: pod-kanboardpod.service: Control process exited, code=exited status=125
Jan 25 13:54:40 podhost-r8-1.lan podman[63106]: Error: no container with name or ID 62cdd29105a4-infra found: no such container
Jan 25 13:54:40 podhost-r8-1.lan systemd[1]: pod-kanboardpod.service: Control process exited, code=exited status=125
Jan 25 13:54:40 podhost-r8-1.lan systemd[1]: pod-kanboardpod.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
-- 
-- The unit pod-kanboardpod.service has entered the 'failed' state with result 'exit-code'.
Jan 25 13:54:40 podhost-r8-1.lan systemd[1]: Failed to start Podman pod-kanboardpod.service.

This does not surprise me, but I don't know what to do about it. I guess the auto-generated systemd service units don't work for my use case, do they? Do you folks have any suggestion on how to accomplish the task that rootless pods created by an unprivileged user would be auto-started by systemd on system startup? Is it possible to specify the path to the pod/containers somehow?

And a related task is that I don't wanna start the pod as root when using systemd. So I guess I have to specify the user running the rootless pod in the service unit, right? Could this be done by simply using "User=" parameter in service definition file?

Looking forward reading your suggestions.

Best regards,
Joerg

Responses