How to Install n8n with Docker: Complete Step-by-Step Guide (2026)

Satyam MishraSatyam Mishra
5 minutes
How to Install n8n with Docker: Complete Step-by-Step Guide (2026)

Why Use Docker for n8n?

If you're planning to self-host n8n, Docker is one of the easiest and most reliable deployment methods available.

Instead of manually installing dependencies, configuring runtimes, and managing updates, Docker packages everything into a portable container that behaves consistently across environments.

Whether you're deploying on a local machine, VPS, cloud server, or home lab, Docker simplifies the process while making upgrades and maintenance much easier.

Some key benefits include:

  • Quick deployment
  • Easy upgrades
  • Portable environments
  • Simplified backups
  • Consistent configurations
  • Better isolation from the host operating system

For most users, Docker is the recommended way to self-host n8n.

Prerequisites

Before getting started, make sure you have:

  • A Linux server, VPS, or local machine
  • Docker installed
  • Docker Compose installed
  • Basic terminal knowledge
  • At least 2 GB of RAM (4 GB recommended)
  • An internet connection for downloading Docker images

If you plan to expose n8n publicly, you'll also need:

  • A domain name
  • HTTPS using a reverse proxy such as Nginx or Traefik
  • Firewall rules configured correctly

Step 1: Install Docker

If Docker isn't already installed, follow the official installation instructions for your operating system.

After installation, verify everything is working by running:

docker --version
docker compose version

Both commands should return the installed version numbers.

Step 2: Create a Docker Compose File

Create a new project directory:

mkdir n8n
cd n8n

Next, create a file named:

docker-compose.yml

Paste the following configuration:

version: "3.8"

services:
  n8n:
    image: n8nio/n8n:latest
    restart: unless-stopped

    ports:
      - "5678:5678"

    environment:
      - N8N_HOST=localhost
      - N8N_PORT=5678
      - N8N_PROTOCOL=http
      - TZ=UTC

    volumes:
      - ./n8n_data:/home/node/.n8n

This configuration creates:

  • An n8n container
  • Persistent workflow storage
  • Automatic restart on server reboot
  • Port mapping to your local machine

Step 3: Start n8n

Run the following command:

docker compose up -d

Docker will download the latest n8n image and start the container.

To verify that everything is running correctly, execute:

docker ps

You should see the n8n container listed as running.

Step 4: Access the n8n Dashboard

Open your browser and navigate to:

http://localhost:5678

If you're using a remote server, replace localhost with your server's IP address or domain name.

On first launch, you'll be prompted to create an owner account. Once completed, you'll have access to the n8n editor where you can begin building workflows.

Step 5: Configure Persistent Storage

Without persistent storage, all workflows and credentials would be lost if the container is removed.

The following volume mapping ensures your data is preserved:

volumes:
  - ./n8n_data:/home/node/.n8n

This directory stores:

  • Workflows
  • Credentials
  • User settings
  • Configuration files

Always include a persistent volume when deploying n8n in production.

Step 6: Secure Your Instance

If your n8n instance is accessible over the internet, security should be a top priority.

Recommended best practices include:

  • Enable HTTPS using a reverse proxy
  • Use strong authentication
  • Restrict server access with a firewall
  • Regularly update Docker images
  • Back up workflow data
  • Store secrets using environment variables instead of hardcoding them

These measures help protect your automation platform from unauthorized access.

Updating n8n

Keeping n8n up to date ensures you receive the latest features, bug fixes, and security improvements.

To update your installation, run:

docker compose pull
docker compose up -d

Docker downloads the newest image while preserving your existing data through the mounted volume.

Common Issues and Fixes

Port Already in Use

If port 5678 is occupied, modify the port mapping in your docker-compose.yml file:

ports:
  - "8080:5678"

Then access n8n at:

http://localhost:8080

Container Keeps Restarting

Check the logs for errors:

docker logs <container-name>

Review the output for configuration issues or missing environment variables.

Data Disappears After Restart

This usually means persistent storage wasn't configured correctly.

Verify that your volume mapping points to a valid directory on the host machine.

Unable to Access n8n

If you're running n8n on a remote server:

  • Confirm the container is running
  • Check firewall rules
  • Ensure the correct port is open
  • Verify reverse proxy configuration if using HTTPS

Frequently Asked Questions

Is Docker the best way to install n8n?

For most users, yes. Docker provides a fast, reliable, and portable deployment method that simplifies updates and maintenance.

Can I run n8n on a Raspberry Pi?

Yes. n8n supports ARM-based devices, making it a popular choice for Raspberry Pi home servers.

Can I update n8n without losing workflows?

Yes. As long as you're using persistent storage, updating the Docker image won't remove your workflows or credentials.

Should I use SQLite or PostgreSQL?

SQLite is suitable for testing and small deployments. PostgreSQL is recommended for production environments with multiple users or high workflow volumes.

Can I deploy n8n on cloud providers?

Absolutely. Many users run n8n on DigitalOcean, Hetzner, AWS, Azure, Google Cloud, and other VPS providers using Docker.

Conclusion

Installing n8n with Docker is one of the quickest and most reliable ways to build a self-hosted workflow automation platform.

With just a few commands, you can deploy a production-ready instance that supports everything from simple task automation to advanced AI-powered workflows.

As your automation needs grow, Docker also makes it easy to update, back up, and scale your deployment without rebuilding your environment from scratch.

If you're serious about owning your automation infrastructure, Docker provides the flexibility and stability needed to run n8n confidently in both personal and business environments.

Ready to Transform Your Marketing, Branding & Advertising Strategy?

Marketing - marketing strategies that drive real connections and lasting impact.

Advertisement - bold ideas and unforgettable campaigns powered by intelligent automation.

Ad Tech - data-driven power for every campaign with advanced tracking and optimization.

Branding - your story, instantly distinct and emotionally true through enhanced creativity.

BOOK A CALL
Satyam Mishra

Satyam Mishra

AI Automation Expert