services: postgres: image: postgres:15 container_name: n8n-postgres restart: unless-stopped environment: POSTGRES_USER: n8n POSTGRES_PASSWORD: n8npass POSTGRES_DB: n8n TZ: Asia/Shanghai volumes: - ./postgres-data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U n8n -d n8n"] interval: 10s timeout: 5s retries: 5 n8n: image: n8nio/n8n:2.2.4 container_name: n8n restart: unless-stopped ports: - "5678:5678" # Mac 上如遇 `Restarting (139)` 可开启以下两项: # platform: linux/amd64 # user: "0:0" environment: DB_TYPE: postgresdb DB_POSTGRESDB_HOST: postgres DB_POSTGRESDB_PORT: 5432 DB_POSTGRESDB_DATABASE: n8n DB_POSTGRESDB_USER: n8n DB_POSTGRESDB_PASSWORD: n8npass TZ: Asia/Shanghai volumes: - ./n8n-data:/home/node/.n8n depends_on: postgres: condition: service_healthy