← Writing

Docker restart policies + a laptop battery survive power cuts with zero extra scripts

restart: unless-stopped plus systemd brings a self-hosted stack back within a minute of power returning — and Cloudflare Tunnel reconnects on its own.

I expected power failures to be the messy part of hosting on a laptop at the office. In practice the entire recovery story is configuration that already exists:

services:
  app:
    restart: unless-stopped

systemd boots Docker, Docker honors the restart policy, and Cloudflare Tunnel re-establishes its outbound connection on its own. The stack recovers within a minute of power returning, with no custom scripts, no wake-on-LAN choreography, nothing to maintain.

And the laptop’s battery is a built-in UPS that desktop servers don’t get — short outages don’t even register. Between the battery and store-and-forward protocols on the other end (email being the classic case), brief power events cost approximately nothing.

← All writing Book a call →
Book a call → WhatsApp