tutorialworks / comments

Comments on our articles
https://www.tutorialworks.com
4 stars 1 forks source link

podman-systemd/ #4

Open rugk opened 3 years ago

rugk commented 3 years ago

How to Start Containers Automatically, with Podman and Systemd

Podman is the super handy tool for running containers on Linux. Whatever you’re using containers for, you can handle it with Podman.

https://www.tutorialworks.com/podman-systemd/

rugk commented 3 years ago

The issue here is that if you add the service to /etc/systemd/system/ it will run on the system bus and as root, because podman generate systemd does not add a User= key to the systemd file.

This of course defeats a big purpose of podman, rootless containers.

I'm not quite sure how to best handle that… You could add it as a user service to $HOME/.config/systemd/user, but that's also inconvenient as you need to start a new systemd session. It's possible, but maybe a simple User= in the service would be better,

johnwmail commented 2 years ago

Hi @rugk, I add this to user systemd , but it does not start on boot, until the user logged in

rugk commented 2 years ago

You can enable systemd user lingering AFAIK so that the user does not need to login. https://serverfault.com/q/846441/350103

johnwmail commented 2 years ago

[johnw@cdn1b ~]$ loginctl list-users UID USER
0 root
1000 johnw
30000 _podman

3 users listed. [johnw@cdn1b ~]$ sudo loginctl enable-linger _podman Could not enable linger: No such process

Anyway, I found the way to start it up on boot with cron.d, thanks.

[johnw@cdn1b ~]$ cat /etc/cron.d/podman

podman

@reboot _podman /usr/bin/podman start php-fpm &

rugk commented 2 years ago

sudo loginctl enable-linger _podman Could not enable linger: No such process

I guess you actually executed sudo loginctl enable linger _podman did not you? No space there, a hyphen… :upside_down_face:

johnwmail commented 2 years ago

sudo loginctl enable-linger _podman Could not enable linger: No such process

I guess you actually executed sudo loginctl enable linger _podman did not you? No space there, a hyphen… upside_down_face

No, I executed this image