Podman User Services and Linger
Everyone repeats that a rootless service dies at logout. On Ubuntu 26.04 it does not - `KillUserProcesses` is false. What lingering changes is measurable: without it the container starts 102 seconds after boot, when somebody logs in.
systemd and Quadlet Guide 22 of 47 Intermediate
- OSUbuntu 26.04 LTS (resolute)
- Podman5.7.0
- Runtimecrun 1.21
- Networknetavark 1.16.1
- TimeAbout 14 min
- Reviewed22 August 2026
Written against the versions above. Podman follows the distribution here rather than a vendor repository, so the version you get is the one Ubuntu shipped. The commands are stable across 5.x.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| PODMAN01 | 192.168.0.24 | Ubuntu 26.04 LTS | Primary Container Host | 2 Core | 4 GB | 50 GB |
Before you start
- guide 40 - the
web.containerunit from that guide, still in place. - The ability to reboot the host, twice. There is no way to observe this without one.
-
Check the claim before acting on it
The advice you will find everywhere is that a rootless service stops when your last session ends, and that
loginctl enable-lingerprevents it. The first half is worth checking rather than believing.KillUserProcessesis what actually decides it, and asking logind directly:b falseFalse. On this system user processes are *not* killed when the session ends, so a running container survives logout with lingering off. The widely repeated advice describes a configuration this host does not have - and several distributions do ship it as
yes, which is why the claim persists.So check your own host rather than inheriting the conclusion. If it says
true, the usual story applies to you. If it saysfalse, lingering still matters, for a different reason.bash Example session loginctl show-user sysadmin --property=LingerLinger=nobusctl get-property org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager KillUserProcessesb falsepodman ps --format 'table {{.Names}} {{.Status}}'NAMES STATUSquadlet-web Up 1 secondExpected result
Linger=no,b false, and a running container.Success conditionYou know what your own logind does at logout, from logind.
-
Reboot, wait, and compare three timestamps
The real question is not logout but boot. With lingering off, does a service with
WantedBy=default.targetstart when the machine starts?The awkward part is observing it: logging in to look is the very thing that starts it. So instead - reboot, wait 95 seconds without connecting, then log in and compare when things happened:
boot 2026-08-22 11:50:06 user@1000.service 2026-08-22 11:51:48 container started 2026-08-22 11:51:48102 seconds after boot, and precisely when the user manager started - which is when I logged in.
So the service is not broken and not disabled.
user@1000.servicesimply did not exist until a session created it, and a unit cannot start before the manager that owns it.default.targetfor your user is reached at your first login, not at boot.For a web service this is the whole bug: the machine reboots at 03:00, nothing serves, and it silently fixes itself the moment somebody SSHes in to investigate.
bash Example session loginctl show-user sysadmin --property=LingerLinger=nouptime -s2026-08-22 11:50:06systemctl show user@1000.service --property=ActiveEnterTimestamp --valueSat 2026-08-22 11:51:48 UTCpodman inspect quadlet-web --format 'started={{.State.StartedAt}}'started=2026-08-22 11:51:48.695802701 +0000 UTCExpected resultA container start time roughly 100 seconds later than the boot time, matching the user manager's start.
Success conditionYou have measured the gap between boot and your service starting.
-
Enable lingering and measure again
sudo loginctl enable-linger sysadmin, then the identical experiment - reboot, wait 95 seconds, log in, read the same three timestamps.boot 2026-08-22 11:52:28 user@1000.service 2026-08-22 11:52:32 container started 2026-08-22 11:52:32Four seconds, against 102. And the clinching detail is the status line: at the moment of that first login the container read
Up About a minute. It had been serving for the whole 95 seconds nobody was watching.The user manager now starts at boot, so
default.targetis reached with nobody logged in and the container starts there.That is all lingering does: it tells logind to start and keep
user@1000.serviceregardless of whether the user has a session. Everything else follows from that one fact - including the logout behaviour on hosts whereKillUserProcessesis true, because there the manager stopping is what takes the container with it.So the rule for any rootless service that must run unattended: enable lingering. It is one command, it needs root once, and it is the difference between a service and a thing that runs while you are watching. If you take one line from this track, it is this one:
sudo loginctl enable-linger $USERThe alternative, if you would rather not depend on it, is a rootful unit in
/etc/containers/systemd/- which starts at boot like any system service, at the cost of the container running as root.bash Example session loginctl show-user sysadmin --property=LingerLinger=yesuptime -s2026-08-22 11:52:28systemctl show user@1000.service --property=ActiveEnterTimestamp --valueSat 2026-08-22 11:52:32 UTCpodman inspect quadlet-web --format 'started={{.State.StartedAt}}'started=2026-08-22 11:52:32.361370136 +0000 UTCpodman ps --format 'table {{.Names}} {{.Status}}'NAMES STATUSquadlet-web Up About a minuteExpected result
Linger=yes, and a container whose start time is at boot rather than at login.Success conditionThe same service now starts without anyone logging in.
Troubleshooting
A rootless service is not running after a reboot until you log in.
Why: Lingering is off, so the user manager starts at first login.
Fix:
sudo loginctl enable-linger $USER. Verify withloginctl show-user $USER --property=Linger.enable-lingerrequires a password in a script.Why: It is a privileged operation on another user's state.
Fix:Run it once at provisioning time rather than from the service. It persists as a file in
/var/lib/systemd/linger/.Lingering is on and the service still does not start at boot.
Why: The unit has no
[Install] WantedBy=, so nothing pulls it intodefault.target.Fix:Add it to the
.containerfile anddaemon-reload. Remembersystemctl enablecannot substitute - see guide 40.You want the opposite - a container that stops when you log out.
Why: Lingering off gives you that only where
KillUserProcessesis true.Fix:Do not rely on session lifetime for this. Stop it explicitly, or bind it to your session with
PartOf=.