Deploying n8n with Docker (Reference Stack)
The reference Docker Compose for n8n production: Postgres, Redis queue mode, Caddy HTTPS, Watchtower upgrades, S3 backups.
Key takeaways
- Five services: postgres, redis, n8n main, n8n worker, caddy.
- Use named volumes for postgres data and n8n config.
- Pin n8n to a minor version tag; let Watchtower handle patch upgrades.
- Daily pg_dump to S3-compatible storage.
This is the reference Docker Compose stack that powers many production n8n deployments. Five services, one Caddyfile, and a backup script. Copy, change the domain, and ship.
The compose file outline
postgres:16-alpine with a persistent volume. redis:7-alpine. n8nio/n8n:1.X.X as the main process (EXECUTIONS_MODE=queue, WEBHOOK_URL set). A second n8nio/n8n:1.X.X as worker (command: worker, scale: 2). caddy:2 fronting :80/:443.
Environment variables that matter
N8N_ENCRYPTION_KEY (generate once, never change), DB_TYPE=postgresdb + DB_POSTGRESDB_* vars, QUEUE_BULL_REDIS_HOST=redis, EXECUTIONS_MODE=queue, WEBHOOK_URL=https://your-domain.com, GENERIC_TIMEZONE.
Caddyfile (3 lines)
your-domain.com { reverse_proxy n8n:5678 } — Caddy handles Let's Encrypt automatically.
Backups
A nightly cron container running pg_dump | gzip | rclone to Backblaze B2. Quarterly restore drill into a sibling compose stack.
Frequently asked questions
- Should I use queue mode from day one?
- Not required for small teams. Flip on once you see >50 concurrent executions or webhook latency rises.
- How big a Postgres do I need?
- Most teams under 100k executions/month fit in 1 vCPU and 2 GB RAM Postgres comfortably.