TemperStack
Beginner8 min readUpdated Mar 13, 2026

How to install n8n with Docker

Quick Answer

Install n8n with Docker by creating a data volume, running the official docker run command mapping port 5678 and mounting n8n_data:/home/node/.n8n, then access http://localhost:5678 for onboarding. Use Docker Compose for production with PostgreSQL. Data persists across restarts via volumes; common issues like port conflicts resolve quickly.

Prerequisites

  1. Docker installed and running (verify with <code>docker --version</code>)
  2. Port 5678 available on host
  3. Basic command-line access
  4. 2GB RAM and 2 CPU cores recommended
  5. Docker Compose (optional for production)
1

Verify Docker Installation

Ensure Docker is installed and running by executing docker --version and docker run hello-world. On Linux, install via sudo apt update && sudo apt install docker.io -y && sudo systemctl enable --now docker; use Docker Desktop for macOS/Windows. Check port 5678 availability with sudo lsof -i :5678.[1][2][3][4]
2

Create Persistent Data Volume

Run docker volume create n8n_data to create a volume for storing workflows, credentials, and config in /home/node/.n8n inside the container, preventing data loss on restarts.[4]
Tip
This step is crucial for persistence; skip only for testing.
3

Run n8n Single-Container (Quick Setup)

docker run -it --rm \
  --name n8n \
  -p 5678:5678 \
  -e GENERIC_TIMEZONE="America/New_York" \
  -e TZ="America/New_York" \
  -e N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true \
  -e N8N_RUNNERS_ENABLED=true \
  -v n8n_data:/home/node/.n8n \
  docker.n8n.io/n8nio/n8n
Replace America/New_York with your timezone (e.g., UTC). This uses SQLite, maps port 5678, enables secure permissions and task runners, and pulls the official image.[4]
Tip
Flags -it --rm allow interactive run and auto-cleanup; data safe in volume.
4

Verify Container is Running

Check with docker ps; look for n8n container 'Up' on 0.0.0.0:5678->5678/tcp. View logs via docker logs n8n if issues arise.[1][4]
5

Access n8n UI and Onboard

Open http://localhost:5678 in browser. Complete onboarding by setting up Owner Account (email/password). Navigate to Workflows tab for new automations and Credentials for integrations.[4]
Tip
No default auth; set strong credentials immediately.
6

Manage Container (Stop/Start)

Stop with Ctrl+C or docker stop n8n. Restart by re-running the docker run command; data persists via volume. For detached mode, remove -it and add -d.[4]
7

Set Up Docker Compose (Production)

Create docker-compose.yml:
version: '3.1'
services:
  n8n:
    image: docker.n8n.io/n8nio/n8n
    ports:
      - "5678:5678"
    environment:
      - GENERIC_TIMEZONE=UTC
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=admin
      - N8N_BASIC_AUTH_PASSWORD=strongpass
    volumes:
      - ./n8n_data:/home/node/.n8n
Run docker compose up -d.[1][3]
Tip
Add PostgreSQL service for production scaling.
8

Enable Basic Auth and Security

In Compose or run command, add -e N8N_BASIC_AUTH_ACTIVE=true -e N8N_BASIC_AUTH_USER=admin -e N8N_BASIC_AUTH_PASSWORD=strongpass for login protection. Set N8N_REINSTALL_MISSING_PACKAGES=true for community nodes.[1][3]
Tip
Essential for exposed instances.
9

Test and Create First Workflow

After access, create a test workflow in the dashboard. Verify persistence by restarting container and checking data remains.[4]
10

Scale to PostgreSQL (Advanced)

Extend Compose with Postgres: add postgres: service and set DB_TYPE=postgresdb, host/user/password vars. Run docker compose up -d.[3]
Tip
Use for production; backup DB regularly.

Troubleshooting

Port 5678 already in use
Check with sudo lsof -i :5678, kill process or change host port (e.g., -p 5679:5678).[1][2]
Permission errors on data volume
Fix ownership: sudo chown -R 1000:1000 n8n_data or use named volume.[1]
Missing community nodes/packages
Set N8N_REINSTALL_MISSING_PACKAGES=true in env vars.[1]
DB init failure (e.g., Duplicate column)
Clear volume docker volume rm n8n_data and recreate; ensure env vars match.[1]
Container fails to start
Check logs docker logs n8n; verify Docker resources (2GB RAM min), pull image manually docker pull docker.n8n.io/n8nio/n8n.[2][4]

Related Guides

More n8n Tutorials

Other Tool Tutorials

Ready to get started with n8n?

Put this tutorial into practice. Visit n8n and follow the steps above.

Visit n8n