How to get Podman containers to automatically start on boot

By default, UCore does not automatically start restart: always containers on system boot. I created an issue on Github about this, as it doesn’t seem like the intended behaviour.

(There is a podman-restart.service which I think is meant to do this for you, but the problem is that the service runs as root and doesn’t appear to start user containers.)

For anyone else like me looking for a solution for this while we wait for the image to natively support it, here’s how you can solve it:

# Copy the system's podman-restart service to the user location
cp /lib/systemd/system/podman-restart.service /var/home/core/.config/systemd/user

# Enable the user service
systemctl --user enable podman-restart.service

# Check that it's running
systemctl --user list-unit-files | grep podman

Then reboot, and your containers will automatically start :+1:

It’s possible you also need to enable “linger” mode on your user session, to prevent containers exiting which you’ve started interactively. I got this information from the Podman troubleshooting page, which is a great resource. You can read the full issue description on their page.

To do that, run:

loginctl enable-linger $UID