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.yml or compose.deploy-prod.yml
  • Both services have restart: always in the compose file (already set)
  • Podman (rootless or rootful)

Rootless Podman (typical on desktop)

  1. Enable user lingering so your user's systemd services run at boot without an active login:

    sudo loginctl enable-linger $USER
    
  2. Enable the Podman restart service for your user:

    systemctl --user enable podman-restart.service
    
  3. Verify the service is enabled:

    systemctl --user is-enabled podman-restart.service
    

    Should 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)

  1. Enable the system-wide Podman restart service:

    sudo systemctl enable podman-restart.service
    
  2. Verify:

    sudo systemctl is-enabled podman-restart.service
    

How it works

  • The compose files set restart: always on both db and app-qa (or app-prod).
  • At boot, podman-restart.service runs podman 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

  1. Wait for the host to finish booting (e.g. 30–60 seconds).

  2. Check that /help returns 200:

    curl -sf -o /dev/null -w "%{http_code}\n" http://localhost:5001/help
    

    For production (port 5000):

    curl -sf -o /dev/null -w "%{http_code}\n" http://localhost:5000/help
    

    Expected: 200.

  3. 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