docker compose 파일
services:
postgres:
image: postgres:16-alpine
container_name: n8n-postgres
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-n8n}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-n8n_password}
POSTGRES_DB: ${POSTGRES_DB:-n8n}
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test:
[
"CMD-SHELL",
"pg_isready -U ${POSTGRES_USER:-n8n} -d ${POSTGRES_DB:-n8n}",
]
interval: 10s
timeout: 5s
retries: 5
n8n:
image: docker.n8n.io/n8nio/n8n:latest
container_name: n8n
restart: unless-stopped
ports:
- "${N8N_PORT:-5678}:5678"
environment:
DB_TYPE: postgresdb
DB_POSTGRESDB_HOST: postgres
DB_POSTGRESDB_PORT: 5432
DB_POSTGRESDB_DATABASE: ${POSTGRES_DB:-n8n}
DB_POSTGRESDB_USER: ${POSTGRES_USER:-n8n}
DB_POSTGRESDB_PASSWORD: ${POSTGRES_PASSWORD:-n8n_password}
N8N_HOST: ${N8N_HOST:-localhost}
N8N_PORT: 5678
N8N_PROTOCOL: ${N8N_PROTOCOL:-http}
N8N_SECURE_COOKIE: ${N8N_SECURE_COOKIE:-false}
WEBHOOK_URL: ${WEBHOOK_URL:-<http://localhost:5678/>}
GENERIC_TIMEZONE: ${GENERIC_TIMEZONE:-Asia/Seoul}
TZ: ${TZ:-Asia/Seoul}
volumes:
- n8n_data:/home/node/.n8n
depends_on:
postgres:
condition: service_healthy
volumes:
n8n_data:
postgres_data:
- PostgreSQL을 compose에 붙이면, n8n “애플리케이션 자체의 내부 저장소”로 자동 사용