Set up Podman rootless containers to auto-start on Ubuntu 24.04 (Nginx Proxy Manager example)
🚀 Set up Podman rootless containers to auto-start on Ubuntu 24.04 (using Nginx Proxy Manager)
When running Podman containers on Ubuntu Server, you may hit these issues:
- Containers do not auto-start on boot
systemctl --usererror:Failed to connect to bus: No medium found- Rootless and root modes get mixed, making containers unmanageable
podman generate systemdcannot find the container- Containers disappear or fail to auto-restart after host reboot
This post summarizes how to correctly enable systemd auto-start for Podman rootless containers, based on a real incident.
🧩 Background: Podman rootless vs systemd
Podman differs from Docker:
| Feature | Docker | Podman |
|---|---|---|
| rootless support | Partial | Full |
| Container store | Root only | Root / user split |
| Auto-start | --restart | systemd (recommended) |
Podman officially recommends using systemd for auto-start, not Docker-style --restart=always.
But you must confirm:
- Which user owns the container (root / ubuntu)
- Whether user systemd is active
- Whether linger is enabled
- Whether a DBus user session exists
Otherwise you’ll see errors like:
Error: no such container
Failed to connect to bus: No medium found
Cannot manage rootless container as root🧨 Issue 1: podman generate systemd cannot find the container
Running as root:
podman generate systemd --name nginx-proxy-managerreturns:
nginx-proxy-manager does not refer to a containerReason:
👉 The container was created by user ubuntu (rootless), not by root. Root cannot see ubuntu’s containers—that’s by design.
Fix:
✔ Switch to ubuntu to generate systemd units:
sudo -iu ubuntu
podman generate systemd --name nginx-proxy-manager --files --new🧨 Issue 2: systemctl --user errors with “No medium found”
Running:
systemctl --user daemon-reloadshows:
Failed to connect to bus: No medium foundReason:
👉 You entered ubuntu via:
sudo -iu ubuntuThis does not start user systemd or a DBus session.
🧩 Fix: properly activate user systemd
1) Enable linger (allow user systemd to run in the background)
sudo loginctl enable-linger ubuntu2) Start [email protected]
sudo systemctl start [email protected](1000 is the ubuntu UID)
3) Re-login as ubuntu via SSH (critical)
Log out all sessions and log back in:
ssh ubuntu@serverNow user systemd and DBus session will load automatically.
4) Verify systemctl works
systemctl --user daemon-reloadNo error means it’s ready.
🧨 Issue 3: systemd service fails to start (rootless networking)
systemd previously reported:
unable to start container ... permission deniedReason:
👉 Rootless containers must be managed by user systemd, not root systemd. Run systemctl in user mode.
🎯 Correct way to auto-start Podman containers (rootless)
Follow these steps 👇
① Switch to ubuntu
sudo -iu ubuntu② Generate systemd service files
podman generate systemd --name nginx-proxy-manager --files --newOutput:
container-nginx-proxy-manager.service③ Copy to user systemd directory
mkdir -p ~/.config/systemd/user
mv container-nginx-proxy-manager.service ~/.config/systemd/user/④ Enable the user service
systemctl --user daemon-reload
systemctl --user enable container-nginx-proxy-manager
systemctl --user start container-nginx-proxy-manager⑤ Check status
systemctl --user status container-nginx-proxy-managerExpect:
Active: active (running)⑥ Force user systemd to stay alive (avoid cold-boot failures)
sudo loginctl enable-linger ubuntu🔥 Reboot test
sudo rebootAfter reboot:
podman ps
systemctl --user status container-nginx-proxy-managerThe container should auto-start.
🏁 Final outcome
You get:
✔ A full Podman rootless auto-start setup
✔ Containers start with the system and auto-restart on crash
✔ User-level systemd bound to your containers
✔ No root needed to manage containers (safer)
✔ Works well for Nginx Proxy Manager, PostgreSQL, and more
📌 Common commands
| Action | Rootless systemd command |
|---|---|
| Start | systemctl --user start container-xxx |
| Stop | systemctl --user stop container-xxx |
| Restart | systemctl --user restart container-xxx |
| Logs | journalctl --user -u container-xxx -f |
| List | podman ps |
📚 Closing notes
With proper user systemd + Podman rootless setup, you can:
- Run persistent services without root
- Automate the entire container lifecycle
- Avoid permission conflicts between Podman and systemd
- Enjoy a safer model than Docker in some scenarios
WenHaoFree