N8N Docker Set Up
Login to Dev Server
eg: Putty to 192.168.1.109
Install Docker:
Step 1: Uninstall Old Docker Versions (Optional, but Recommended)
If you have any old or unofficial Docker packages installed, it's best to remove them first. If you're sure you don't, you can skip this.
Bash
sudo apt-get remove docker docker-engine docker.io containerd runc
Step 2: Update Package Index and Install Prerequisites
These packages are needed to allow apt
to use a repository over HTTPS and to manage software properties.
Bash
sudo apt-get update sudo apt-get install -y \ ca-certificates \ curl \ gnupg \ lsb-release \ software-properties-common \ apt-transport-https
Your initial attempt at this was mostly okay but got a bit tangled later. This single command should cover the necessary prerequisites.
Step 3: Add Docker’s Official GPG Key
This key is used to verify the authenticity of the Docker packages.
Bash
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
Step 4: Set Up the Docker Stable Repository
This command adds Docker's official APT repository to your system's list of sources.
Bash
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
(Make sure there's a space after echo
and before the opening double quote. This was the main issue in your attempt.)
Step 5: Update Package Index Again
Now that Docker's repository has been added, update apt
's package index so it knows about the new Docker packages.
Bash
sudo apt-get update
You should see lines in the output referring to https://download.docker.com/linux/ubuntu
.
Step 6: Install Docker Engine, CLI, containerd, and Docker Compose Plugin
This command installs the latest stable version of Docker and the Docker Compose plugin (which allows you to use docker compose
with a space).
Bash
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
- If you get an error here saying a package can't be found, double-check that Step 4 and 5 completed without error and that the Docker repository was indeed added and updated.
Step 7: Verify Docker Installation
Check that Docker Engine is installed and running correctly.
Bash
sudo docker run hello-world
This will download and run a small test image. If it works, you'll see a confirmation message.
Also, check the versions:
Bash
docker --version
docker compose version
(Note the space in docker compose
for the plugin version).
Step 8: Manage Docker as a Non-Root User (Highly Recommended)
To avoid having to type sudo
for every Docker command: a. Add your user to the docker
group (the group might already exist): bash sudo usermod -aG docker ${USER}
(Replace ${USER}
with your actual username if it's not automatically picked up, e.g., sudo usermod -aG docker hexucation
)
b. For this change to take effect, you need to log out and log back in, or you can activate the group change for your current terminal session with: bash newgrp docker
(Note: newgrp docker
starts a new shell. You might prefer to just open a new terminal window after logging out and back in).
c. After logging back in or starting a new session/terminal, verify you can run Docker commands without sudo
: bash docker run hello-world
Follow these steps carefully, ensuring each command completes successfully before moving to the next. Pay close attention to spaces and exact commands, especially for Step 4. This should get Docker and Docker Compose (plugin) installed correctly on your Ubuntu 20.04 system.
Install Docker Compose
sudo apt install docker-compose-plugin
Verify Installation
Check if the plugin is installed:
bash Copy code docker compose version
Use docker compose
Command
Try running your Compose file again:
bash Copy code docker compose up
NGINX Example
- Install NGINX:
bash Copy code sudo apt install nginx
Configure NGINX for n8n: Create a file /etc/nginx/sites-available/n8n
with the following content:
nginx
Copy code
server { listen 80; server_name public-domain>; location / { proxy_pass http://localhost:5678; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; client_max_body_size 50M; } }
Enable the site and reload NGINX:
bash Copy code sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl reload nginx
If you get an 400 error this is the fix:
server {
# Existing configuration...
client_header_buffer_sTest the configuration for syntax errors:
bash Copy code sudo nginx -t
Reload NGINX to apply changes:
bash Copy code sudo systemctl reload nginx
ize 16k;
large_client_header_buffers 4 32k;
}