Podman: Document using rootless container with systemd

Created on 21 Aug 2019  路  5Comments  路  Source: containers/podman

Rootless podman works great with systemd to manage services ran as a user.
However it would be nice to add some docs for that somewhere, or tweak generate systemd for the rootless use case.

The 2 difficult points I ran into was:

  • the service must depends on [email protected] so the user dbus session is initialized and the /run user folder exists
  • KillMode=none as explained in #3657

Here is a working unit:

[Unit]
Description=nginx
[email protected]
[email protected]

[Service]
Type=simple
KillMode=none
ExecStartPre=-/usr/bin/podman rm -f nginx
ExecStartPre=/usr/bin/podman pull nginx
ExecStart=/usr/bin/podman run --name=nginx -p 8080:80 nginx
ExecStop=/usr/bin/podman stop nginx
Restart=always
User=nginx
Group=nginx

[Install]
WantedBy=multi-user.target

All 5 comments

PRs and Blogs welcomed. :^)

Where do you think I could contribute such a doc ?

rootless_tutorial.md ?

I'd drop it in rootless_tutorial at least to start. I'd make a new section for it in that md file.

I think both of these could be pretty easily dropped into generate systemd as defaults based on a rootless.IsRootless() check

Was this page helpful?
0 / 5 - 0 ratings