Lesson 6medium10 min

Running n8n Self-Hosted with Docker

Deploy a persistent, self-hosted n8n instance using Docker and Docker Compose.

Learning Objectives

  • Write a production-ready docker-compose.yml for n8n
  • Configure volume persistence for workflows and credentials
  • Set secure environment variables and webhook tunnel settings

Running n8n Self-Hosted with Docker

Self-hosting n8n gives you complete data sovereignty and zero per-execution fees. Docker Compose is the recommended deployment method.

Docker Compose Configuration

Create a directory named n8n-docker and save the following docker-compose.yml:

version: '3.8'

services:
  n8n:
    image: docker.n8n.io/n8nio/n8n:latest
    container_name: n8n_core
    restart: unless-stopped
    ports:
      - "5678:5678"
    environment:
      - N8N_HOST=localhost
      - N8N_PORT=5678
      - N8N_PROTOCOL=http
      - NODE_ENV=production
      - WEBHOOK_URL=http://localhost:5678/
      - GENERIC_TIMEZONE=UTC
    volumes:
      - n8n_data:/home/node/.n8n

volumes:
  n8n_data:
    external: false
Advertisement

Starting the Container

Launch the service in detached mode:

docker compose up -d

Check the startup logs:

docker compose logs -f n8n

Navigate to http://localhost:5678 in your browser to complete owner account creation.