How to Install Discourse on Hetzner or DigitalOcean with Docker (Production Guide)
Direct Answer: To install Discourse on a Linux VPS, provision an Ubuntu 24.04 LTS instance with at least 2 vCPUs and 4GB RAM, configure a 4GB swap file, install Docker Engine, clone the official discourse/discourse_docker repository, run ./discourse-setup to configure your domain and SMTP credentials, and bootstrap the container.
Hardware & OS Prerequisites
Discourse is a Ruby on Rails application backed by PostgreSQL and Redis. Running it in production requires:
- A modern 64-bit Linux VPS (Ubuntu 24.04 LTS recommended).
- Minimum 2 vCPU and 4GB RAM (2GB works with swap, but 4GB prevents out-of-memory container crashes during rebuilds).
- A fully qualified domain name (FQDN) with DNS A/AAAA records already pointed to the VPS.
- Active SMTP credentials (Amazon SES, Mailgun, Postmark, or SendGrid).
Step 1: Configure Swap Space
Even on servers with 4GB RAM, Discourse asset pre-compilation during container rebuilds demands temporary bursts of memory. Create a 4GB swap file:
# Create 4GB swap
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
# Make persistent on reboot
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
Step 2: Install Docker Engine
Install the official Docker Engine runtime via the convenience script:
sudo apt-get update && sudo apt-get upgrade -y
curl -fsSL https://get.docker.com | sudo sh
sudo systemctl enable --now docker
Step 3: Clone Discourse Docker & Run Setup
Clone the official repository into /var/discourse:
sudo git clone https://github.com/discourse/discourse_docker.git /var/discourse
cd /var/discourse
sudo chmod 700 containers
sudo ./discourse-setup
The interactive setup tool will prompt for your forum domain, admin email, SMTP server address, port (typically 587), and authentication credentials. It automatically provisions a free Let's Encrypt SSL certificate.
Post-Install Hardening & Maintenance
- Automated Backups: Configure daily offsite backup synchronization to Cloudflare R2 or Amazon S3.
- Firewall (UFW): Open only ports 22 (SSH), 80 (HTTP), and 443 (HTTPS).
- Security Updates: Enable unattended security upgrades for the host Linux OS.
Need Production-Hardened Discourse Setup?
Skip the server setup headache. We provision hardened Discourse environments with Cloudflare CDN, private S3 backups, and 24/7 proactive monitoring on our managed Discourse hosting plan.
Explore Managed Discourse Plans →Have questions about your software architecture?
Book a free 20-minute strategy call with our principal software architects. We will evaluate your prototype or workflow and provide a clear technical roadmap.