Skip to main content

On This Page

Safe Remote Server Reboot Guide for Ubuntu with Docker and Cloudflare Tunnel

2 min read
Share

These articles are AI-generated summaries. Please check the original sources for full details.

For Ubuntu Desktop with Docker and Cloudflare Tunnel

This guide ensures your remote server comes back online automatically after a reboot when you have no physical access to the machine. It addresses scenarios where reliable uptime is critical for services deployed with Docker and accessed via Cloudflare Tunnel.

Prerequisites

Your server should have Docker with containers configured with restart: unless-stopped, an enabled SSH server, Cloudflare Tunnel for remote access, and auto-login enabled (Ubuntu Desktop).

Why This Matters

Remote server reboots are inevitable for security updates or maintenance; however, without automated recovery, downtime can be significant. While ideal models assume service continuity, a misconfiguration in restart policies can lead to extended outages, costing valuable operational hours and potentially impacting user access to critical applications.

Key Insights

  • systemctl is-enabled <service>: This command verifies if a systemd service is set to start on boot (2023).
  • restart: unless-stopped: Docker’s restart policy ensures containers automatically restart after crashes or server reboots, excluding intentional stops.
  • Cloudflare Tunnel: Provides secure remote access without exposing the server directly to the public internet.

Working Example

# Check if Docker starts on boot
sudo systemctl is-enabled docker

# If not enabled, enable it
sudo systemctl enable docker

# Check container restart policies
docker inspect --format ' - {{.Name}}: {{.HostConfig.RestartPolicy.Name}}' $(docker ps -q)

Practical Applications

  • Stripe/Coinbase: Utilize this approach to ensure uninterrupted operation of critical backend services during routine server maintenance.
  • Pitfall: Forgetting to set restart: unless-stopped in Docker Compose files leads to containers failing to restart after a reboot, resulting in service unavailability.

References:

Continue reading

Next article

Solved: Automate Twitter/X Posts when a New Blog Post is Published (RSS to API)

Related Content