Containers survive host reboot
This guide explains how to make the Rediflow database and app containers start automatically after a (virtualized) host reboot.
Prerequisites
- Rediflow deployed with
compose.deploy-qa.ymlorcompose.deploy-prod.yml - Both services have
restart: alwaysin the compose file (already set) - Podman (rootless or rootful)
Rootless Podman (typical on desktop)
-
Enable user lingering so your user's systemd services run at boot without an active login:
sudo loginctl enable-linger $USER -
Enable the Podman restart service for your user:
systemctl --user enable podman-restart.service -
Verify the service is enabled:
systemctl --user is-enabled podman-restart.serviceShould output
enabled.
After reboot, podman-restart.service runs and starts all containers with restart: always. The Rediflow stack (db + app) will come up automatically.
Rootful Podman (e.g. in LXD container)
-
Enable the system-wide Podman restart service:
sudo systemctl enable podman-restart.service -
Verify:
sudo systemctl is-enabled podman-restart.service
How it works
- The compose files set
restart: alwayson bothdbandapp-qa(orapp-prod). - At boot,
podman-restart.servicerunspodman start --all --filter restart-policy=always. - Containers with that policy are started. The app depends on the db; start order is handled by Podman.
Verification after reboot
-
Wait for the host to finish booting (e.g. 30–60 seconds).
-
Check that
/helpreturns 200:curl -sf -o /dev/null -w "%{http_code}\n" http://localhost:5001/helpFor production (port 5000):
curl -sf -o /dev/null -w "%{http_code}\n" http://localhost:5000/helpExpected:
200. -
Or run the test script (Ubuntu):
./scripts/test-reboot-survival.sh
Troubleshooting
| Issue | Resolution |
|---|---|
| Containers not starting after reboot | Ensure loginctl enable-linger (rootless) or systemctl enable podman-restart (rootful) |
| Service fails at boot | Check journalctl --user -u podman-restart (rootless) or journalctl -u podman-restart (rootful) |
| App returns 5xx | DB may not be ready yet; wait 10–20 seconds and retry |
| Port not listening | Ensure no firewall blocks 5000/5001; check podman ps |
See also
- Deploy QA and production — Base deployment
- Deploy on containerized Ubuntu desktop — Nested containers
- Deploy on containerized Rocky Linux — Rocky Linux