Can you run n8n on Docker?

Quick Answer: Yes. n8n provides an official Docker image (n8nio/n8n) that can be run with a single command, supports persistent volumes for workflow data, and works with Docker Compose for production setups including PostgreSQL. Self-hosted n8n on Docker is free under the Sustainable Use License and is the recommended deployment path.

Running n8n on Docker

Docker is the recommended deployment method for self-hosted n8n. The official image is maintained by the n8n team and updated with each release.

Quick Start — Single Container

Run n8n with one command, storing data in a named volume:

docker run -it --rm \
  --name n8n \
  -p 5678:5678 \
  -v n8n_data:/home/node/.n8n \
  n8nio/n8n

Access the editor at http://localhost:5678.

Production Setup — Docker Compose

For production, use Docker Compose with PostgreSQL for data storage:

services:
  postgres:
    image: postgres:15
    environment:
      POSTGRES_USER: n8n
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: n8n
    volumes:
      - postgres_data:/var/lib/postgresql/data

  n8n:
    image: n8nio/n8n
    restart: always
    ports:
      - "5678:5678"
    environment:
      DB_TYPE: postgresdb
      DB_POSTGRESDB_HOST: postgres
      DB_POSTGRESDB_USER: n8n
      DB_POSTGRESDB_PASSWORD: ${POSTGRES_PASSWORD}
      N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY}
    volumes:
      - n8n_data:/home/node/.n8n
    depends_on:
      - postgres

Recommended Environment Variables

  • N8N_ENCRYPTION_KEY: Encrypts credentials at rest
  • N8N_HOST: External hostname (for webhooks)
  • WEBHOOK_URL: Full URL for webhooks (important behind reverse proxy)
  • N8N_BASIC_AUTH_ACTIVE: Enables basic auth for the editor

Reverse Proxy

For public deployments, place n8n behind Caddy, Nginx, or Traefik for TLS termination. This is required for webhooks from external services.

Backup

  • Back up the PostgreSQL database nightly
  • Export workflows with the n8n CLI: n8n export:workflow --all --output=/backups
  • Store encryption key securely (loss = inability to decrypt credentials)

Scaling Considerations

  • Default single-instance runs webhook and worker processes together
  • For high throughput, enable "queue mode" with Redis and separate worker containers
  • Worker containers use the same image with --worker flag

Resource Requirements

  • Minimum: 1 vCPU, 1 GB RAM
  • Recommended for production: 2 vCPU, 4 GB RAM
  • Disk: 10 GB for database and logs

Related Questions

Written & reviewed by Rafal Fila · Last updated:

Related Tools

Related Rankings

Dive Deeper

comparison

Keystroke vs n8n in 2026: Agent-Built TypeScript vs the Visual Canvas

Keystroke, launched in July 2026 by Y Combinator W24 company Sprint Labs, is a code-first automation platform where AI coding agents write workflows as TypeScript in the user's repository. n8n, founded in 2019, is the most widely deployed source-available visual workflow platform, with 200,000+ users and a $2.5 billion valuation. This comparison covers the agent-authored versus canvas building models, durable execution, licensing (Elastic License 2.0 vs the Sustainable Use License), verified July 2026 pricing including Keystroke's usage metering, and the maturity gap between a days-old platform and an established ecosystem.

comparison

QuantumBPM vs Camunda 2026: Single-Binary Challenger vs the BPMN Incumbent

QuantumBPM (launched 2026, Coroid s.r.o., Slovakia) packages a BPMN 2.0 runtime and DMN 1.5 decision engine into one Go binary backed by Temporal and PostgreSQL. Camunda (Berlin, founded 2013) is the category incumbent: Camunda 7 (Apache 2.0, in maintenance) and the Zeebe-based Camunda 8 platform. This comparison covers product structure, architecture, DMN TCK conformance with recording dates, deployment, pricing, and vendor maturity, verified July 2026.

case-study

Migrating 23 Make Scenarios to Self-Hosted n8n: a 3-Week Breakdown

Anonymized retrospective of a DTC ecommerce brand migrating 23 Make scenarios to a self-hosted n8n instance over three weeks. Tooling cost dropped from $348/month on Make Teams to roughly $12/month on a Hetzner VPS, but credential and webhook recreation consumed about 40% of total project time.