n8n Docker Linux
7 min read Automation

How to Self-Host n8n on Linux Using Docker — Complete Setup Guide

Most automation platforms force you into their cloud. n8n gives you freedom - but installing it manually leads to dependency nightmares. This Docker method gives you a production-ready automation server in under 10 minutes, with persistent storage and auto-restart built in.

Why Docker Beats Manual n8n Installation

Most Linux users instinctively reach for npm install when setting up Node.js applications like n8n. This approach works - until you need to upgrade Node.js, deal with dependency conflicts, or migrate to a new server. The manual method leaves your automation vulnerable to system changes.

Docker containers solve these problems by packaging n8n with all its dependencies in an isolated environment. Think of it like shipping your automation tools in a standardized container that runs the same way on any Linux machine - no dependency hell, no version conflicts.

Key benefit: Docker gives you one-command upgrades (docker pull n8nio/n8n) and preserves your workflows even if the underlying system changes. The containerized approach is how enterprises run n8n in production.

System Prerequisites

Before installing, ensure your Linux system meets these requirements:

  • Ubuntu/Debian (tested on Ubuntu 22.04 LTS) or any distro with bash support
  • sudo privileges to install system packages
  • 2GB RAM minimum (4GB recommended for production)
  • 10GB free storage for Docker images and persistent data

While the commands work on most Linux flavors, we recommend Ubuntu/Debian for the smoothest experience. The tutorial assumes you're comfortable running terminal commands.

Installing Docker (First-Time Setup)

If Docker isn't already installed on your system, run these commands sequentially:

Step 1: Update Package Index

 sudo apt update sudo apt upgrade -y 

This refreshes your package lists and upgrades existing software - crucial for avoiding conflicts with new installations.

Step 2: Install Docker

 sudo apt install docker.io -y 

The -y flag automatically confirms the installation. Docker.io is the maintained version in Ubuntu repositories.

Step 3: Start and Enable Docker

 sudo systemctl start docker sudo systemctl enable docker 

These commands launch Docker immediately and configure it to start automatically on system boot.

Verification: Run docker --version to confirm installation. You should see version 24.0+ on modern systems.

n8n Installation Steps

With Docker ready, installing n8n takes just three commands:

Step 1: Create Data Directory

 mkdir ~/n8n-data 

This folder will store your workflows and credentials persistently.

Step 2: Set Permissions

 sudo chown -R 1000:1000 ~/n8n-data 

This grants the Docker user (UID 1000) ownership of the data folder.

Step 3: Launch n8n Container

 docker run -d \   --name n8n \   -p 5678:5678 \   -v ~/n8n-data:/home/node/.n8n \   n8nio/n8n 

Breakdown of the flags:

  • -d: Runs container in detached mode
  • --name: Names your container for easy management
  • -p: Maps port 5678 (n8n web UI) to host
  • -v: Mounts your data folder into the container

Success check: Visit http://your-server-ip:5678 to access the n8n web interface. You should see the login screen within 30 seconds.

Solving Linux Permission Issues

The most common installation problem involves Linux file permissions. If n8n can't write to your data directory, you'll see errors about "permission denied" in the Docker logs.

These commands ensure proper access:

 sudo chmod -R 755 ~/n8n-data sudo chown -R 1000:1000 ~/n8n-data 

The first command sets read/write permissions, while the second assigns ownership to the Docker user. Always run these after creating new folders for Docker volumes.

Troubleshooting tip: Use docker logs n8n to view real-time logs if the web UI doesn't load. Permission errors appear clearly here.

Production-Ready Configuration

The basic installation works, but these enhancements make it production-grade:

Auto-Restart on Crash/Reboot

 docker update --restart unless-stopped n8n 

Resource Limits (Optional)

 docker update --memory 4G --cpus 2 n8n 

Custom Port (If 5678 Conflicts)

 docker run -p 5680:5678 [...] 

For enterprise deployments, consider adding:

  • Reverse proxy (Nginx/Apache)
  • SSL certificates
  • Database backend

Daily Maintenance Commands

Once running, these Docker commands manage your n8n instance:

Start/Stop Container

 docker start n8n docker stop n8n 

View Logs

 docker logs -f n8n 

Update n8n Version

 docker pull n8nio/n8n docker stop n8n docker rm n8n [Re-run original docker run command] 

Pro tip: Create a bash script with your docker run command for easy version upgrades. Store it in ~/n8n-setup.sh.

Watch the Full Tutorial

See the complete installation process with live troubleshooting at the 3:45 mark, where we demonstrate solving common permission errors.

Video tutorial: Installing n8n on Linux with Docker

Key Takeaways

Docker transforms n8n from a fragile installation to a resilient automation engine. By containerizing your workflows, you gain portability, easier upgrades, and system isolation.

In summary: The Docker method requires slightly more initial setup than npm install, but saves countless hours in maintenance and troubleshooting. For any serious automation project, containerization is the professional choice.

Frequently Asked Questions

Common questions about self-hosting n8n

Docker provides container isolation which prevents dependency conflicts with other system packages. When you install n8n via npm, it shares your system's Node.js environment and can break when other applications require different Node versions.

The containerized approach also simplifies upgrades - just pull the latest n8n image instead of manually managing Node.js versions and npm packages.

  • Isolation: No conflicts with other apps
  • Portability: Same container runs anywhere
  • Upgrades: Single-command version updates

This method works on any Linux distribution that supports Docker, including Ubuntu, Debian, CentOS, and Fedora. The commands shown are specifically tested on Ubuntu/Debian systems but will work with minor adjustments on other distributions.

The key requirement is having Docker Engine installed. Most modern Linux distributions include Docker in their package repositories or provide easy installation methods.

  • Debian/Ubuntu: Native package support
  • RHEL/CentOS: Requires EPEL repository
  • Arch Linux: Available in community repos

After successful installation, access the n8n web interface by opening http://your-server-ip:5678 in any web browser. If you're installing on a local machine, use http://localhost:5678.

The default credentials are username "admin" and password "password" - you should change these immediately in the user management settings.

  • Default port: 5678
  • Local access: http://localhost:5678
  • Remote access: http://server-ip:5678

The persistent data folder stores all n8n workflows, credentials, and execution data. Without mapping this folder, all your automation configurations would be lost when the container restarts.

The -v flag in Docker creates this persistent storage mapping between the container and your host system. This means your workflows survive container updates and server reboots.

  • Location: ~/n8n-data by default
  • Contents: Workflows, credentials, logs
  • Backup: Copy this folder for disaster recovery

Yes, you can run multiple Docker containers simultaneously on the same host. Each container operates in isolation with its own network stack and filesystem.

The only limitation is port conflicts - if another service uses port 5678, you'll need to map n8n to a different port using the -p flag (e.g., -p 5680:5678).

  • Isolation: Each container gets its own environment
  • Networking: Containers can communicate internally
  • Resources: Share host CPU/RAM efficiently

Updating is simple with Docker. First stop the running container, then pull the latest n8n image with 'docker pull n8nio/n8n', and finally restart the container using the same run command.

Your workflows and data remain intact since they're stored in the persistent volume. The update process typically takes under a minute with no downtime for simple workflows.

  • Step 1: docker stop n8n
  • Step 2: docker pull n8nio/n8n
  • Step 3: Re-run your docker run command

n8n requires at least 2GB RAM and 2 CPU cores for basic operation. For production use with multiple workflows, 4GB RAM is recommended.

Storage needs depend on your workflow volume but start with at least 10GB for the Docker volume. These requirements assume n8n is the primary service running on the host.

  • Minimum: 2GB RAM, 2 CPU cores
  • Recommended: 4GB RAM, 4 CPU cores
  • Storage: 10GB+ for workflows

GrowwStacks helps businesses implement automation workflows, AI integrations, and scalable systems tailored to their operations. We specialize in n8n deployments that go beyond basic installation.

Our team handles enterprise requirements like high availability setups, database backends, team collaboration features, and secure remote access. We offer ongoing maintenance plans that keep your automation running smoothly.

  • Custom n8n configurations for your business needs
  • Enterprise features like HA and database backends
  • Free consultation to discuss your automation goals

Ready to Deploy n8n in Your Business?

Manual installation is just the beginning. GrowwStacks builds enterprise-grade n8n systems with high availability, automated backups, and team collaboration features. Get your free consultation to discuss scaling automation across your organization.