Docker Compose configuration template for n8n with various options, using a shared .env
file.
docker-compose.yml
: Default Docker Compose configuration for n8n (full with PostgreSQL and Redis).env
: File containing environment variables for configurationcompose-configs/
: Directory containing customized Docker Compose configurationsdocker-compose.n8n-only.yml
: Run n8n with minimal configurationdocker-compose.n8n-sqlite.yml
: Run n8n with SQLitedocker-compose.n8n-postgres.yml
: n8n with PostgreSQLdocker-compose.n8n-redis.yml
: n8n with Redis
start.bat
: Script to easily select and run configurations on Windowsstart.ps1
: PowerShell script to easily select and run configurations on Windowsstart.sh
: Script to easily select and run configurations on Linux/macOS
- Docker and Docker Compose installed
- Ports used (can be changed in the
.env
file):- n8n: 5678
- PostgreSQL: 5432
- Redis: 6379
Before starting, you should check and edit the environment variables in the .env
file:
# Edit .env file
nano .env
On Windows (Command Prompt):
start.bat
On Windows (PowerShell):
.\start.ps1
On Linux/macOS:
chmod +x start.sh
./start.sh
n8n only (minimal configuration):
docker-compose -f compose-configs/docker-compose.n8n-only.yml up -d
n8n with SQLite:
docker-compose -f compose-configs/docker-compose.n8n-sqlite.yml up -d
n8n with PostgreSQL:
docker-compose -f compose-configs/docker-compose.n8n-postgres.yml up -d
n8n with Redis:
docker-compose -f compose-configs/docker-compose.n8n-redis.yml up -d
Full (n8n + PostgreSQL + Redis):
docker-compose up -d
To stop n8n, use the command corresponding to the configuration you chose:
# If using a file in the compose-configs directory
docker-compose -f compose-configs/docker-compose.[config-name].yml down
# If using the default configuration
docker-compose down
Example:
docker-compose -f compose-configs/docker-compose.n8n-postgres.yml down
# If using a file in the compose-configs directory
docker-compose -f compose-configs/docker-compose.[config-name].yml logs -f
# If using the default configuration
docker-compose logs -f
# If using a file in the compose-configs directory
docker-compose -f compose-configs/docker-compose.[config-name].yml logs -f n8n
# If using the default configuration
docker-compose logs -f n8n
You can customize the configuration in the .env
file:
N8N_HOST
: n8n hostnameN8N_PORT
: n8n port (default: 5678)N8N_PROTOCOL
: Protocol (http/https)N8N_ENCRYPTION_KEY
: Encryption key (important for security)GENERIC_TIMEZONE
: Timezone (default: Asia/Ho_Chi_Minh)
DB_POSTGRESDB_USER
: PostgreSQL usernameDB_POSTGRESDB_PASSWORD
: PostgreSQL passwordDB_POSTGRESDB_DATABASE
: Database nameDB_POSTGRESDB_PORT
: PostgreSQL port (default: 5432)
REDIS_HOST
: Redis hostnameREDIS_PORT
: Redis port (default: 6379)
Data is stored in the following directories:
./postgres-data/
: PostgreSQL data./redis-data/
: Redis data./n8n-data/
: n8n data
- Change
N8N_ENCRYPTION_KEY
in the.env
file before using in production - Change database passwords in the
.env
file for production environments - If deploying publicly, configure HTTPS and user authentication