- 129 Views
- 29/10/2025
How to Install n8n with Docker Compose on Ubuntu 22.04
n8n is a powerful open-source workflow automation tool that lets you connect apps and automate tasks — similar to Zapier or Make. In this tutorial, we’ll go step-by-step through how to install n8n using Docker Compose on an Ubuntu 22.04 server.
1. Update Your System
Before installing anything, make sure your system is up to date:
2. Install Docker and Docker Compose
Install Docker
sudo apt install ca-certificates curl gnupg lsb-release -y
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y
Verify Docker is working
sudo systemctl start docker
sudo docker run hello-world
If you see “Hello from Docker!”, your installation was successful ✅
3. Create a Folder for n8n
Let’s create a directory to store n8n configuration and data:
sudo chown -R 1000:1000 /opt/n8n/n8n_data
cd /opt/n8n
4. Create the Docker Compose File
Paste the following content:
version: '3.7'
services:
n8n:
image: n8nio/n8n:latest
restart: always
ports:
- "5678:5678"
environment:
- GENERIC_TIMEZONE=Asia/Ho_Chi_Minh
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=admin
- N8N_BASIC_AUTH_PASSWORD=yourpassword
- N8N_HOST=n8n.example.com
- N8N_PORT=5678
- N8N_PROTOCOL=http
- WEBHOOK_URL=http://your-server-ip:5678/
volumes:
- ./n8n_data:/home/node/.n8n
🔹 Change the username and password for security.
🔹 Replace your-server-ip or n8n.example.com with your real IP or domain.
5. Start n8n
Run the container in the background:
Check the running containers:
6. Fix Permission Errors (if any)
If you see this error:
Run the following commands:
sudo docker compose down
sudo chown -R 1000:1000 /opt/n8n/n8n_data
sudo docker compose up -d
This gives the container’s user permission to write to the mounted folder.
7. Access the n8n Web Interface
Now open your browser and go to:
Log in using your credentials:
Password: yourpassword
8. (Optional) Enable HTTPS with a Reverse Proxy
For production use, you should run n8n behind a reverse proxy like Traefik or Nginx Proxy Manager to enable Let’s Encrypt SSL certificates.
Example (Nginx Proxy Manager):
Proxy http://localhost:5678
Enable SSL with Let’s Encrypt
Use your domain: n8n.example.com
9. Backup Your Data
All your workflows, credentials, and settings are stored in:
To back up, simply copy or sync this folder regularly.
| Command | Description |
|---|---|
sudo docker compose up -d | Start n8n |
sudo docker compose down | Stop n8n |
sudo docker compose restart | Restart n8n |
sudo docker compose logs -f | View live logs |
sudo docker exec -it n8n /bin/bash | Enter the container |
Thanks for visit my website
