n8n Docker Guide: Deploy and Scale with Containers
Running n8n with Docker is the recommended approach for production self-hosted deployments. Docker ensures consistent environments, easy updates, persistent data storage, and simple scaling. This guide covers everything from a basic Docker setup to a production-ready deployment with PostgreSQL, SSL, and monitoring.
Why Docker for n8n
n8n can be installed via npm, but Docker is better for production because:
- Isolation: n8n runs in its own container; no conflicts with other system software
- Easy updates:
docker pull n8nio/n8n:latest+ restart = updated n8n - Persistence: Docker volumes keep your data safe across container restarts
- Reproducibility: Same environment on any machine
- Easy SSL: Use nginx reverse proxy container alongside n8n
Quick Start with Docker
The simplest Docker setup for development/testing:
Open http://localhost:5678. This uses SQLite by default and stores data in ~/.n8n.
Note: --rm removes the container when stopped. Remove it for persistent deployments.
Production Docker Compose Setup
For production, use Docker Compose with PostgreSQL:
Create .env file:
Start:
Adding SSL with nginx
Add an nginx reverse proxy with Let's Encrypt:
Environment Variables Reference
Key n8n environment variables:
| Variable | Description | Example |
|---|---|---|
N8N_BASIC_AUTH_ACTIVE | Enable basic auth | true |
N8N_HOST | Domain name | n8n.example.com |
N8N_ENCRYPTION_KEY | Encrypt stored credentials | 32-char random string |
DB_TYPE | Database type | postgresdb or sqlite |
WEBHOOK_URL | External webhook base URL | https://n8n.example.com/ |
EXECUTIONS_TIMEOUT | Max workflow execution time | 3600 (seconds) |
EXECUTIONS_DATA_MAX_AGE | Delete execution data after (days) | 30 |
N8N_LOG_LEVEL | Logging verbosity | info or debug |
Updating n8n
n8n runs database migrations automatically on startup. Check the changelog before major version updates.
Backups
Set up automated daily backups via cron.
Recommended Tools
- n8n — The automation platform
- Docker — Container runtime
- DigitalOcean — Simple VPS for n8n hosting ($20-40/month)
- Hetzner — Affordable EU cloud for GDPR compliance
- Cloudflare — DNS + DDoS protection for your n8n instance
Related articles
n8n vs Make.com vs Zapier: a 2026 honest comparison
No affiliate fluff — where each tool wins, where it breaks, and what we actually run.
Self-hosting n8n: a production-grade setup guide
Queue mode, workers, backups, and the security defaults you should never skip.
Complete n8n Guide: Everything You Need to Build Powerful Automations
The definitive n8n guide — nodes, credentials, triggers, and production-grade patterns.