This project provides a complete Docker Compose setup for running n8n with PostgreSQL and Redis.
- 🚀 n8n - Latest version with web interface
- 🐘 PostgreSQL - Persistent database for workflows and data
- 🔴 Redis - Caching and session storage
- 📁 Persistent volumes - Data survives container restarts
- 🔐 Basic authentication - Secure access to n8n
- 🌐 Custom networking - Isolated container communication
-
Clone and setup:
cd c:\dev\n8n cp .env.example .env
-
Edit the
.env
file with your preferred settings:- Change the default password
- Set your timezone
- Configure database credentials
- Add email settings (optional)
-
Start the services:
docker-compose up -d
-
Access n8n:
- Open your browser and go to: http://localhost:5678
- Login with the credentials from your
.env
file
docker-compose up -d
docker-compose down
docker-compose logs -f n8n
docker-compose pull
docker-compose up -d
docker-compose exec postgres pg_dump -U n8n n8n > backup.sql
docker-compose exec -T postgres psql -U n8n n8n < backup.sql
c:\dev\n8n\
├── docker-compose.yml # Main Docker Compose configuration
├── .env.example # Environment variables template
├── .env # Your environment variables (create from .env.example)
├── .gitignore # Git ignore file
├── README.md # This file
├── custom/ # Custom n8n nodes and configurations
├── backups/ # Database backups
└── logs/ # Application logs
Key variables you should customize in .env
:
N8N_BASIC_AUTH_USER
- Your admin usernameN8N_BASIC_AUTH_PASSWORD
- Your admin passwordDB_POSTGRESDB_PASSWORD
- Database passwordN8N_ENCRYPTION_KEY
- Encryption key for sensitive dataGENERIC_TIMEZONE
- Your timezone
Place custom n8n nodes in the custom/
directory. They will be automatically loaded by n8n.
If port 5678 is already in use, change it in docker-compose.yml:
ports:
- "8080:5678" # Use port 8080 instead
Check if PostgreSQL is running:
docker-compose logs postgres
To start fresh (
docker-compose down -v
docker-compose up -d
- Change default passwords before production use
- Use HTTPS in production (consider adding a reverse proxy)
- Regularly backup your database
- Keep Docker images updated