Deploying to Hetzner with Docker
Hetzner Cloud offers the best price-performance ratio in cloud computing. Their CX22 instance (2 vCPUs, 4GB RAM) costs about 4 euros per month — a fraction of equivalent AWS, GCP, or Azure instances. Here is how to deploy a containerized application on Hetzner.
Server Provisioning
Create a Hetzner Cloud account and spin up a CX22 or CX32 instance with Ubuntu 24.04. Add your SSH key during creation. Hetzner servers are provisioned in under 30 seconds. Run initial setup: update packages, create a non-root user, configure UFW firewall (allow 22, 80, 443), and install Docker with the official repository.
Traefik as Reverse Proxy
Use Traefik as your reverse proxy and automatic TLS certificate manager. Define a Docker Compose service for Traefik that watches for new containers and automatically configures routing and HTTPS. Traefik obtains Let's Encrypt certificates automatically — no manual certificate management. Add labels to your application containers to define routing rules.
Application Deployment
Build your Docker image in CI (GitHub Actions) and push it to GitHub Container Registry. On the server, pull the latest image and restart the container. For zero-downtime deployments, use Docker Compose rolling updates or run two container instances behind Traefik and switch traffic after health checks pass.
Persistent Data
Use Docker volumes for database data and file uploads. Back up volumes to Hetzner Object Storage (S3-compatible, very cheap) using a cron job. For PostgreSQL, use pg_dump inside a scheduled container rather than copying volume files directly. Test your restore procedure regularly — a backup you have never restored is not a backup.
Monitoring and Maintenance
Install Prometheus and Grafana in Docker containers for monitoring. Use node-exporter for system metrics and cAdvisor for container metrics. Set up alerts for disk space, memory usage, and container restart loops. For logs, use Docker logging driver with json-file and a log rotation policy. Alternatively, ship logs to Grafana Loki for centralized searching. Automate OS updates with unattended-upgrades to keep your server patched.
Written by AIDToolStack Editorial
The AIDToolStack editorial team reviews developer tools, AI products, and MCP servers with hands-on testing and honest assessments. We use the tools we review every day in production.
References & Further Reading
Related Posts
Sponsor Our Newsletter
Reach thousands of developers who are actively evaluating AI tools, MCP servers, and dev infrastructure. Our weekly newsletter goes to engaged technical decision-makers.
All sponsored content is clearly labeled per our editorial policy.