How to Install n8n on Linux Using Docker

Posted: 17th July 2025 by Jab in AI
Tags: , ,

How to Install n8n on Linux Using Docker

n8n is an open-source workflow automation tool that lets you connect apps and automate repetitive tasks with minimal effort. Think of it as a self-hosted alternative to Zapier, but with more flexibility and no vendor lock-in.

In this guide, we’ll walk you through installing n8n on a Linux server using Docker. This method keeps the install process simple, consistent, and easy to maintain.

Why Use Docker?

  • Isolation: Keeps n8n and its dependencies separate from your system.

  • Portability: Easily move your setup to another server.

  • Simplicity: No need to install Node.js or configure complex environments manually.

Prerequisites

Before you get started, make sure your system has:

  • A Linux server (Ubuntu, CentOS, Debian, etc.)

  • Docker and Docker Compose installed

  • Basic command-line knowledge

  • A working domain (optional, but recommended if you plan to expose n8n publicly)

Step 1: Install Docker & Docker Compose

If Docker isn’t installed yet, run the following commands:

# Update system packages
sudo apt update && sudo apt upgrade -y

# Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

# Install Docker Compose (if needed)
sudo apt install docker-compose -y

Verify Docker is running:

docker –version
docker-compose –version

Step 2: Create a Directory for n8n

Organize your n8n files:

mkdir -p ~/n8n-docker
cd ~/n8n-docker

Step 3: Create a Docker Compose File

Create a docker-compose.yml file in the ~/n8n-docker folder:

vim docker-compose.yml

Paste the following configuration:

version: “3.8”

services:
n8n:
image: n8nio/n8n:latest
restart: unless-stopped
ports:
– “5678:5678”
environment:
– GENERIC_TIMEZONE=America/Denver # Set your timezone
– N8N_BASIC_AUTH_ACTIVE=true # Enable basic auth
– N8N_BASIC_AUTH_USER=admin # Set your username
– N8N_BASIC_AUTH_PASSWORD=changeme # Set your password
volumes:
– ./n8n_data:/home/node/.n8n

Notes:

  • Change N8N_BASIC_AUTH_USER and N8N_BASIC_AUTH_PASSWORD to secure credentials.

  • Port 5678 is the default n8n port.

  • ./n8n_data stores your workflows and credentials persistently.

Step 4: Start n8n

In your project directory, run:

docker-compose up -d

This will pull the latest n8n image, set up the container, and start it in the background.

Step 5: Access n8n

Open your browser and go to:

http://<your-server-ip>:5678

Log in using the username and password you set in the docker-compose.yml file.

Optional: Secure with HTTPS and a Reverse Proxy

If you want to expose n8n to the internet, it’s highly recommended to run it behind a reverse proxy like NGINX with Let’s Encrypt SSL.

You can use tools like:

  • NGINX Proxy Manager

  • Traefik

  • Caddy

This adds HTTPS encryption and makes it easier to manage domains.

Step 6: Manage n8n

Common commands:

# View logs
docker-compose logs -f

# Stop n8n
docker-compose down

# Restart n8n
docker-compose restart

# Update n8n to the latest version
docker-compose pull
docker-compose up -d

 

Conclusion

That’s it! You now have n8n running on your Linux server using Docker.

This setup is great for:

  • Automating internal workflows

  • Connecting APIs

  • Handling data pipelines

  • Building no-code/low-code backend systems

Resources