n8n Docker: Complete Installation and Configuration Guide (2026)
Installing n8n with Docker is the fastest way to deploy your own automation instance. This step-by-step guide covers Docker Compose, HTTPS, and essential environment variables.

William Aklamavo
April 8, 2026
n8n Docker: Complete Installation and Configuration Guide (2026)
n8n Docker is the deployment method preferred by teams who want total control over their data. In 15 minutes, you can have your own n8n instance ready to automate your business processes — without paying the cloud subscription.
Why Install n8n with Docker?
- Complete isolation: n8n runs in its own container with no system conflicts
- One-command updates:
docker pull n8nio/n8n:latest - Persistent data: Docker volumes preserve your workflows across restarts
- Reproducible: The same
docker-compose.ymlworks on any server - Free: n8n Community Edition is open source with no workflow limits
Prerequisites
- A Linux VPS (Ubuntu 22.04 recommended) with at least 1 GB RAM
- Docker Engine 24.x or higher
- Docker Compose V2
- A domain name pointed to your server (for HTTPS)
Installing n8n with Docker Compose
Step 1: Create the directory structure
mkdir -p ~/n8n/data
cd ~/n8n
Step 2: Create docker-compose.yml
version: '3.8'
services:
n8n:
image: n8nio/n8n:latest
container_name: n8n
restart: unless-stopped
ports:
- "5678:5678"
environment:
- N8N_HOST=n8n.your-domain.com
- N8N_PORT=5678
- N8N_PROTOCOL=https
- WEBHOOK_URL=https://n8n.your-domain.com/
- GENERIC_TIMEZONE=Europe/London
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=admin
- N8N_BASIC_AUTH_PASSWORD=your-strong-password
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_DATABASE=n8n
- DB_POSTGRESDB_USER=n8n_user
- DB_POSTGRESDB_PASSWORD=your-db-password
volumes:
- ./data:/home/node/.n8n
depends_on:
- postgres
postgres:
image: postgres:16-alpine
container_name: n8n_postgres
restart: unless-stopped
environment:
- POSTGRES_DB=n8n
- POSTGRES_USER=n8n_user
- POSTGRES_PASSWORD=your-db-password
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
postgres_data:
Step 3: Start n8n
docker compose up -d
docker compose ps
docker compose logs n8n
HTTPS Configuration with Nginx
server {
listen 443 ssl;
server_name n8n.your-domain.com;
ssl_certificate /etc/letsencrypt/live/n8n.your-domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/n8n.your-domain.com/privkey.pem;
location / {
proxy_pass http://localhost:5678;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
Get your SSL certificate: certbot --nginx -d n8n.your-domain.com
Essential Environment Variables
| Variable | Description | Example |
|---|---|---|
| N8N_HOST | Your instance domain | n8n.mydomain.com |
| WEBHOOK_URL | Full URL for webhooks | https://n8n.mydomain.com/ |
| GENERIC_TIMEZONE | Execution timezone | Europe/London |
| N8N_ENCRYPTION_KEY | Credential encryption key | Generate with openssl rand -hex 32 |
Updating n8n
cd ~/n8n
docker compose pull
docker compose up -d
Automated Backups
#!/bin/bash
DATE=$(date +%Y%m%d)
docker exec n8n_postgres pg_dump -U n8n_user n8n > ~/backups/n8n_backup_$DATE.sql
find ~/backups -name "n8n_backup_*.sql" -mtime +30 -delete
Add to cron: 0 3 * * * /bin/bash ~/backup-n8n.sh
Conclusion
You now have an n8n Docker instance running with HTTPS and automated backups. To build autonomous AI agents on your n8n instance, check out our n8n & Make automation service.
