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.
Prerequisites
Your server should have:
- Docker with containers using
restart: unless-stopped - SSH server enabled
- Cloudflare Tunnel for remote SSH access
- (Ubuntu Desktop) Auto-login configured
Pre-Reboot Checklist
Run these commands on the server via SSH before rebooting.
1. Check Docker Starts on Boot
sudo systemctl is-enabled docker
Expected: enabled
If not enabled:
sudo systemctl enable docker
2. Check SSH Starts on Boot
sudo systemctl is-enabled ssh
Expected: enabled
If not enabled:
sudo systemctl enable ssh
3. Check Container Restart Policies
docker inspect --format ' - {{.Name}}: {{.HostConfig.RestartPolicy.Name}}' $(docker ps -q)
Expected: All containers should show unless-stopped or always
4. (Ubuntu Desktop Only) Configure Auto-Login
Check if you have a desktop environment:
sudo systemctl status gdm3
If GDM is active (Ubuntu Desktop), configure auto-login:
sudo nano /etc/gdm3/custom.conf
Add under [daemon]:
[daemon]
AutomaticLoginEnable=True
AutomaticLogin=your-username
Apply changes:
sudo systemctl restart gdm3
Verify configuration:
cat /etc/gdm3/custom.conf
Note: The keyring warnings (
gkr-pam: couldn't unlock the login keyring) are normal and won't affect SSH or Docker.
Quick Verification Script
Run this single script to check everything:
echo "=== Pre-Reboot Check ==="
echo "Docker enabled: $(sudo systemctl is-enabled docker)"
echo "SSH enabled: $(sudo systemctl is-enabled ssh)"
echo ""
echo "Running containers:"
docker ps --format " - {{.Names}}: {{.Status}}"
echo ""
echo "Restart policies:"
docker inspect --format ' - {{.Name}}: {{.HostConfig.RestartPolicy.Name}}' $(docker ps -q) 2>/dev/null || echo " No containers running"
Expected output:
=== Pre-Reboot Check ===
Docker enabled: enabled
SSH enabled: enabled
Running containers:
- n8n-cloudflared: Up 33 hours
- n8n-prod: Up 33 hours (healthy)
- n8n-dev: Up 33 hours (healthy)
- n8n-postgres-prod: Up 33 hours (healthy)
- n8n-postgres-dev: Up 33 hours (healthy)
- cloudflared: Up 36 hours
Restart policies:
- /n8n-cloudflared: unless-stopped
- /n8n-prod: unless-stopped
- /n8n-dev: unless-stopped
- /n8n-postgres-prod: unless-stopped
- /n8n-postgres-dev: unless-stopped
- /cloudflared: unless-stopped
Safe to Reboot Checklist
| Check | Required Status |
|---|---|
| Docker enabled on boot | enabled |
| SSH enabled on boot | enabled |
| All containers restart policy |
unless-stopped or always
|
| Auto-login (Ubuntu Desktop) | Configured for your user |
Reboot Procedure
Step 1: Reboot the Server
sudo reboot
Your SSH session will disconnect immediately.
Step 2: Wait
Wait 2-3 minutes for:
- Server to boot
- Auto-login to complete (Ubuntu Desktop)
- Docker service to start
- Containers to start
- Cloudflare Tunnel to establish connection
Step 3: Reconnect
ssh myserver
Step 4: Verify
Once connected, verify all containers are running:
docker ps
All containers should show Up X minutes status.
Troubleshooting
Can't reconnect after 5 minutes
| Possible Cause | Solution |
|---|---|
| Docker didn't start | Needs physical access to check |
| Stuck at login screen | Auto-login not configured (Ubuntu Desktop) |
| Tunnel container failed | Check with docker ps when you regain access |
| Network/ISP issue | Wait and retry |
Preventive Test (Optional)
Before rebooting, test that containers restart properly:
# Stop all containers
docker stop $(docker ps -q)
# Wait a few seconds
sleep 5
# Check if they auto-restart (they won't - you need to start them manually after stop)
# This is expected - "unless-stopped" only auto-starts after daemon restart, not after manual stop
# Start them manually for this test
cd ~/cloudflare-tunnel && docker compose up -d
cd ~/n8n-stack && docker compose up -d
# Verify
docker ps
Docker User Permissions
If Docker requires sudo, add your user to the docker group:
sudo usermod -aG docker $USER
newgrp docker
Verify:
docker ps
This persists across reboots. The newgrp command is only needed for the current session.
Summary
Safe to reboot when:
- ✅
sudo systemctl is-enabled docker→enabled - ✅
sudo systemctl is-enabled ssh→enabled - ✅ All containers have
restart: unless-stopped - ✅ (Ubuntu Desktop) Auto-login configured
Reboot command:
sudo reboot
Reconnect after 2-3 minutes:
ssh myserver
Top comments (0)