Approved 2024/02/05 16:48 by psycore (version: 2) | Approver: psycore
n8n installation with Docker Compose
n8n installation with Docker Compose, Let's Encrypt SSL certificate and Basic Auth. For systems that are not directly accessible on the Internet, the HTTP method can also be selected (not recommended, however).
1st Docker installation (Debian)
1.1 Uninstall old versions
sudo apt-get remove docker docker-engine docker.io containerd runc
1.2 Repo installation
1.2.1 Update apt and activate HTTPS
sudo apt-get update sudo apt-get install \ ca-certificates \ curl \ gnupg \ lsb-release sudo mkdir -m 0755 -p /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/debian/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/debian \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
1.2.2 Add Docker GPG Key
sudo mkdir -m 0755 -p /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
1.2.3 Repo setup
echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
1.3 Install Docker Engine
sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
2. install Docker Compose
sudo apt-get install docker-compose-plugin
3. DNS entry
Type: A Name: n8n IP address: <IP_OF_YOUR_SERVER>
4. create Docker Compose file
/somedirectory/docker-compose.yml
4.1 HTTP-01 Challenge (Standard TLS Port 443)
4.2 DNS-01 Challenge (Alternative TLS Ports)
The DNS provider must be adapted accordingly here.
5. create .env file
/somedirectory/n8n/.env
# Folder where data should be saved DATA_FOLDER=/root/n8n/ # The top level domain to serve from DOMAIN_NAME=example.com # The subdomain to serve from SUBDOMAIN=n8n # DOMAIN_NAME and SUBDOMAIN combined decide where n8n will be reachable from # above example would result in: https://n8n.example.com # The user name to use for authentication - IMPORTANT ALWAYS CHANGE! N8N_BASIC_AUTH_USER=user # The password to use for authentication - IMPORTANT ALWAYS CHANGE! N8N_BASIC_AUTH_PASSWORD=password # Optional timezone to set which gets used by Cron-Node by default # If not set New York time will be used GENERIC_TIMEZONE=Europe/Berlin # The email address to use for the SSL certificate creation SSL_EMAIL=user@example.com
6. create data directory
mkdir /somedirectory/n8n
7. start and stop
7.1 Start
sudo docker compose up -d
7.1.1 Start with output
sudo docker compose up
7.2 Stop
sudo docker compose stop
8 Update
8.1 Update image
docker pull n8nio/n8n
8.2 Restart
# Stop current setup sudo docker compose stop # Delete it (will only delete the docker-containers, data is stored separately) sudo docker compose rm # Then start it again, in ingteractive mode to check for errors sudo docker compose up
If everything runs without errors, end the process with CTRL+C and start it in daemon mode
sudo docker compose up -d