Movatterモバイル変換


[0]ホーム

URL:


Skip to content
Search Gists
Sign in Sign up

Instantly share code, notes, and snippets.

@plembo
Last activeNovember 25, 2025 14:26
    • Star(4)You must be signed in to star a gist
    • Fork(0)You must be signed in to fork a gist

    Select an option

    Save plembo/9dda7e1fe28ac4f7ef4a1a5ef43ee069 to your computer and use it in GitHub Desktop.
    Automatically start pod on reboot

    NOTE: This was written while I was experimenting with using podman in lieu of docker, something I'm now looking at again.Not all docker images work with podman, so be prepared to struggle with the system and to engage in many fruitless Internet searches.

    Intro

    OK, so who knew podman containers won't automatically start on reboot? Yeah. Me neither.

    Found out after a family member complained about getting a 500 error when trying to reach aPiGallery2 instance I had set up on the home server.

    Fixing this is easy, as detailed in Pratham Patel's "How to Autostart Podman Containers?" over onLinux Handbook: A systemd service is created and enabled for each container.

    Steps

    What follows is my own summary of the steps Pratham sets out, modified for use in an environment where podman containers are owned and run by a nonprivileged user (in this case, "pods": see myOne (non root) podman account to rule them all). Here, we'll use my "pigallery2" container as the target container.

    1. As root (or sudo root) enable lingering (sudo loginctl enable-linger).
    2. Log in as the container user (ssh pods@example, simply doing an "su - pods" or "sudo su - pods will not suffice).
    3. Shut down the container (podman stop pigallery2).
    4. Create a systemd service for the container (podman generate systemd --new --name "pigallery2" >pigallery2.service).
    5. Move the systemd file to the user's systemd service directory (~/.config/systemd/user/, if this doesn't exist create it).
    6. Reload systemd for the user (systemctl --user daemon-reload).
    7. Enable the service (systemctl --user enable pigallery2).
    8. Reboot.
    9. Log back in as the container user and verify the container is running (podman ps).
    10. Check service status (systemctl --user status pigallery2).

    References

    Prathan Patel. "How to Autostart Podman Containers?".Linux Handbook, 28 September 2022,https://linuxhandbook.com/autostart-podman-containers/.

    Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

    [8]ページ先頭

    ©2009-2025 Movatter.jp