| Tested on | Red Hat Enterprise Linux 10.2 (Coughlan) |
|---|---|
| Package | podman-5.8.2-5.el10_2.x86_64 |
| Applies to | Linux hosts with Podman — rootless logout behavior; reboot survival applies rootful and rootless |
| Privilege | Rootless Podman user for logout tests; [sudo](/sudo-command-in-linux/) for loginctl enable-linger |
| Scope | Why rootless containers stop at SSH logout, loginctl enable-linger and disable-linger, logout versus reboot survival, --restart policies, podman-restart.service, should-start-on-boot filter, Quadlet pointer, and diagnostic commands. Does not cover full rootless setup, every restart-policy option, complete Quadlet tutorial, or container exit-code diagnosis. |
| Related guides | Start, stop, and restart containers Run containers with podman run What is Podman? |
A detached podman run -d container can look healthy until you log out of SSH or reboot the host. Logout survival and reboot survival are different problems with different fixes. This guide shows how to reproduce each case, which knob applies, and how to confirm your host is configured correctly.
loginctl enable-linger) and boot restart (--restart, podman-restart.service). It does not diagnose containers that exit immediately with error codes — see container exits immediately when podman ps -a shows Exited right after podman run.
Container stops when the rootless user logs out
Rootless Podman ties container processes to your user systemd session. Start a long-running detached container as a normal user (not root):
podman run -d --name logout-demo registry.access.redhat.com/ubi9/ubi-minimal:latest sleep infinityConfirm it is running before you disconnect:
podman ps --filter name=logout-demoSample output:
CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES
824831da2573 registry.access.redhat.com/ubi9/ubi-minimal:latest sleep infinity 3 seconds ago Up 3 seconds logout-demoLog out of SSH completely — end every interactive session for that user — and log back in. Without linger enabled, list containers again:
podman ps -a --filter name=logout-demoSample output after the last session ended:
CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES
824831da2573 registry.access.redhat.com/ubi9/ubi-minimal:latest sleep infinity 10 minutes ago Exited (137) 10 minutes ago logout-demoExited (137) means the process received SIGKILL. systemd tore down user@UID.service when your final session closed, which killed conmon and the container workload. Rootful containers on the system instance do not hit this logout path — this symptom is almost always rootless plus linger disabled.
Why rootless containers can stop at logout
systemd-logind tracks login sessions per user. Rootless Podman stores containers under that user's cgroup tree, managed by user@UID.service.
When linger is off and your last session ends:
- logind stops the per-user systemd manager for that login period
- the user's runtime directory under
/run/user/UIDis removed - processes in the user slice — including
podman,conmon, and container PID 1 — are terminated
Linger tells logind to keep user@UID.service running even when no one is logged in. That is the upstream-supported way to run rootless daemons that must outlive SSH.
Fix logout survival with loginctl enable-linger
An administrator enables linger for the Podman user. Replace podmantest with your account:
sudo loginctl enable-linger podmantestWhen you run the command for your own account from an elevated shell:
sudo loginctl enable-linger "$(id -un)"enable-linger exits silently on success. Confirm the setting:
loginctl show-user podmantest -p LingerSample output:
Linger=yesStart a fresh container with linger active:
podman run -d --name logout-demo2 registry.access.redhat.com/ubi9/ubi-minimal:latest sleep infinityEnd your SSH session and reconnect. The container should still be up:
podman ps --filter name=logout-demo2Sample output:
CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES
4a64dfa9b9d6 registry.access.redhat.com/ubi9/ubi-minimal:latest sleep infinity 2 minutes ago Up 2 minutes logout-demo2Linger keeps the user manager alive; it does not restart a container you already stopped.
Disable linger and what it does not do
Turn linger off when you no longer want background user services after logout:
sudo loginctl disable-linger podmantestVerify:
loginctl show-user podmantest -p LingerSample output:
Linger=noLinger only affects the user systemd session lifecycle. It does not:
- set a Podman restart policy on any container
- recreate containers you removed
- start stopped containers after a host reboot
Treat linger as the logout fix. Reboot survival needs --restart plus podman-restart.service, or a systemd/Quadlet unit.
Logout survival and reboot survival are different
| Problem | Main mechanism |
|---|---|
| Process killed at logout | loginctl enable-linger keeps user@UID.service running rootless |
| Process exits while host stays up | Podman --restart policy (always, unless-stopped, on-failure) |
| Start again after host reboot | podman-restart.service plus restart policy (should-start-on-boot) |
| Durable server service | Quadlet unit with Restart= and WantedBy= |
loginctl enable-linger alone does not restart a manually launched container after reboot. After power loss or reboot, every container process is gone until something explicitly starts it again.
Container is stopped after reboot
No container process survives an OS reboot. Create one without a restart policy to see the default:
podman run -d --name reboot-demo registry.access.redhat.com/ubi9/ubi-minimal:latest sleep infinityAfter the host comes back, list all containers:
podman ps -a --filter name=reboot-demoSample output:
CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES
7e8ffee07b78 registry.access.redhat.com/ubi9/ubi-minimal:latest sleep infinity 2 hours ago Exited (137) 2 hours ago reboot-demoThe container record still exists in Podman storage, but the workload is stopped. Something must start it again — you, podman-restart.service, or a systemd unit.
Configure a Podman restart policy
Add --restart=always when you create the container so Podman tracks it for runtime restarts and boot:
podman run -d --name reboot-demo --restart=always registry.access.redhat.com/ubi9/ubi-minimal:latest sleep infinityRead the stored policy:
podman inspect --format '{{json .HostConfig.RestartPolicy}}' reboot-demoSample output:
{"Name":"always","MaximumRetryCount":0}--restart tells Podman what to do when the main process exits while Podman is running on a live host. Boot is a separate step handled by podman-restart.service.
podman-restart.service
Podman ships a systemd unit that starts eligible containers after boot. Inspect the system unit:
systemctl cat podman-restart.serviceThe ExecStart line on RHEL 10.2 Podman 5.8.2 is:
ExecStart=/usr/bin/podman $LOGGING start --all --filter should-start-on-boot=trueCheck whether the system service is enabled:
systemctl status podman-restart.service --no-pagerSample output (truncated):
○ podman-restart.service - Podman Start All Containers With Restart Policy Set To Always
Loaded: loaded (/usr/lib/systemd/system/podman-restart.service; disabled; preset: disabled)
Active: inactive (dead)On this lab host the unit exists but is disabled until you enable it. Rootful hosts that rely on CLI-created containers should run:
sudo systemctl enable --now podman-restart.serviceRootless users need linger so user@UID.service runs at boot, then enable the user unit:
systemctl --user enable --now podman-restart.serviceInspect the user unit when present:
systemctl --user cat podman-restart.servicePackage layout varies by distribution — verify the unit on your host instead of assuming paths.
always vs unless-stopped after reboot
Both policies can restart a container when its process dies on a running host. They differ after reboot and after manual stop.
| Policy | Restarts on process exit (host up) | Starts after reboot via podman-restart.service |
|---|---|---|
always |
Yes | Yes — while the container exists and was not removed |
unless-stopped |
Yes | Only if you had not run podman stop before the reboot |
List containers Podman considers boot candidates:
podman ps -a --filter should-start-on-boot=true --format '{{.Names}} {{.Status}}'With reboot-demo (always) running and unless-demo (unless-stopped) manually stopped:
reboot-demo Up 43 secondsunless-demo does not appear because podman stop recorded an explicit stop. Start it again and the filter includes it:
podman start unless-demoRe-run the boot filter now that unless-demo is running again:
podman ps -a --filter should-start-on-boot=true --format '{{.Names}} {{.Status}}'Sample output:
reboot-demo Up About a minute
unless-demo Up 2 secondsAfter a simulated reboot — user runtime stopped and podman-restart.service started — only reboot-demo came back up; the stopped unless-stopped container stayed exited.
Why --restart is not meaningless
A common misconception is that --restart only matters with Quadlet. That is not accurate.
--restarthandles process exit while the Podman host is runningpodman-restart.servicehandles the after-reboot start for containers in theshould-start-on-bootfilter
Standalone podman run --restart=always plus an enabled podman-restart.service is a valid pattern for lab boxes and single-container hosts. For production services you usually move to Podman Quadlet and systemd so journalctl, dependency ordering, and systemctl restart apply.
Quadlet is the durable service answer
For a long-running server workload, declare the container in a Quadlet .container file and let systemd own lifecycle:
[Container]
Image=registry.access.redhat.com/ubi9/ubi-minimal:latest
ContainerName=web-demo
[Service]
Restart=always
[Install]
WantedBy=default.targetFor this rootless example, default.target starts the service with the user manager. A rootful system Quadlet commonly uses multi-user.target instead.
For rootless Quadlet, place the .container file in the user Quadlet search path, include [Install] WantedBy=default.target, run systemctl --user daemon-reload, and start the generated service with systemctl --user start UNIT.service. Quadlet applies the [Install] section automatically; do not run systemctl --user enable on the generated service. Enable linger when the service must start at boot without anyone logging in.
For rootful Quadlet, use the system Quadlet path, include an appropriate [Install] target such as multi-user.target, run sudo systemctl daemon-reload, and start the generated service with sudo systemctl start UNIT.service.
This article does not walk through Quadlet syntax — see Podman Quadlet and systemd for the full workflow.
Do not combine Podman and systemd restart policy blindly
When systemd generates or manages the unit, systemd should own restart behavior:
[Service]
Restart=alwaysDo not normally add --restart=always inside the same systemd-managed container definition. One lifecycle manager should decide when the workload restarts. Layering both can produce double restarts or make failures harder to read in logs.
Diagnostic checklist
When a container disappeared or stayed stopped, run these checks in order.
Restart policy on the container:
podman inspect --format '{{json .HostConfig.RestartPolicy}}' CONTAINERLinger for the rootless user:
loginctl show-user USER -p LingerSystem restart service (pick root or user):
systemctl status podman-restart.serviceFor rootless workloads, check the user-scoped unit the same way:
systemctl --user status podman-restart.serviceBoot-eligible containers:
podman ps -a --filter should-start-on-boot=trueQuadlet-managed service:
systemctl status SERVICERootless Quadlet units use the user manager instead:
systemctl --user status SERVICETroubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Rootless container Exited (137) after SSH logout |
Linger disabled; user slice torn down | sudo loginctl enable-linger USER; recreate or podman start the container |
| Container stopped after reboot, no restart policy | Default policy does not survive boot | Recreate with --restart=always or unless-stopped; enable podman-restart.service |
always container still stopped after reboot |
podman-restart.service disabled |
systemctl enable --now podman-restart.service (root) or user unit with linger |
unless-stopped missing after reboot |
You ran podman stop before reboot |
podman start CONTAINER; policy skips manually stopped containers |
| Rootless boot restart never runs | Linger off; user manager not active at boot | Enable linger, then systemctl --user enable --now podman-restart.service |
References
- Podman rootless documentation
- loginctl(1) — enable-linger
- systemd user@.service
- Podman podman-restart.service unit
Summary
Rootless Podman containers stop at logout when linger is disabled because they live under user@UID.service, and logind tears that down when your last session ends. sudo loginctl enable-linger USER keeps the user manager running so detached containers can survive SSH disconnect — but linger does not bring containers back after a reboot.
Reboot is a separate problem. Every container process dies when the host restarts; Podman only starts them again when a restart policy marks them for boot (should-start-on-boot) and podman-restart.service runs — or when systemd/Quadlet owns the unit. Use --restart=always when you want boot survival; use unless-stopped when manual podman stop should be remembered across reboot.
For production services, move from ad hoc podman run to Quadlet with Restart= on the unit, enable linger for rootless boot, and avoid stacking Podman --restart on top of systemd-managed containers. When the container exits immediately instead of at logout, read the exit code before changing restart policy — that is a different troubleshooting path.

