π What is n8n?
n8n is an open source workflow automation tool that connects 200+ services (Google Sheets, Slack, Telegram, etc.) to automate complex tasks.
β
Codeless interface
β
Self-hosted available
β
Highly scalable node-based structure
π₯ Think of it as a business-grade version of “If This Then That (IFTTT)”!
—.
π³ Why install with Docker Compose?
Benefits | Description |
---|---|
Simplicity | 1 file to set up without complicated dependencies! |
Consistency | Ensure your dev/test/production environments are the same |
Extensibility | Easy to integrate additional services such as PostgreSQL, Redis, etc. |
Manageability | Integrated management with docker-compose command |
—]
βοΈ Preparation
- Install Docker
See official documentation
sudo apt update && sudo apt install docker.io docker-compose
- Create a directory
mkdir n8n-docker && cd n8n-docker
—]
π οΈ write docker-compose.yml (basic)
version: '3.8'
services:
n8n:
image: n8nio/n8n
restart: always
ports:
- "5678:5678" # Web interface ports.
environment:
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER=admin # π username
- N8N_BASIC_AUTH_PASSWORD=securepassword123! # π Password
volumes:
- N8N_DATA:/home/node/.N8N # Ensure data persistence.
networks:
- n8n_network
volumes:
n8n_data: # Create volumes
networks:
n8n_network:
—.
π₯ Advanced Settings (DB + HTTPS)
version: '3.8'
services:
postgres:
image: postgres:13
environment:
POSTGRES_USER: n8n_user
POSTGRES_PASSWORD: db_password123!
POSTGRES_DB: n8n_db
volumes:
- pg_data:/var/lib/postgresql/data
n8n:
image: n8nio/n8n
depends_on:
- postgres
environment:
DB_TYPE: postgresdb
DB_POSTGRESDB_DATABASE: n8n_db
DB_POSTGRESDB_USER: n8n_user
DB_POSTGRESDB_PASSWORD: db_password123!
DB_POSTGRESDB_HOST: postgres
N8N_HOST: yourdomain.com # π Domain Settings
N8N_PROTOCOL: https # π Force HTTPS
VUE_APP_URL_BASE_API: https://yourdomain.com/
volumes:
- n8n_data:/home/node/.n8n
ports:
- "443:5678" # HTTPS standard port mapping
volumes:
n8n_data:
pg_data:
# π‘ Tip: Add an Nginx reverse proxy for extra security!
—.
π Run and stop commands
# start
docker-compose up -d
# Check the status
docker-compose ps
# View logs
docker-compose logs -f n8n
# Stop (preserve data)
docker-compose down
—]
π Initial Setup Guide
- Enter the Access Address:
http://μλ²IP:5678
- Create a workflow
- β Set trigger (starting point) with
Add Node
- π Connect nodes to configure automation flow
- Example: Receive Gmail β Send Slack notification
- β Set trigger (starting point) with
- **Save Credentials π Securely manage your integration service API keys!
—.
β οΈ Precautions & Optimization Tips
- **Security enhancements
- Require basic authentication (
N8N_BASIC_AUTH_ACTIVE=true
) - Encrypt sensitive data by setting
N8N_ENCRYPTION_KEY
.
- Require basic authentication (
- backup strategy
# backup volume data docker run --rm -v n8n_data:/source -v $(pwd):/backup busybox tar cvf /backup/n8n_backup.tar /source
- **Resource Limitations
# Add docker-compose.yml deploy: Resources: limits: cpus: '1.0' memory: 2G
—.
π― Finish
> “n8n + Docker Compose = infinite automation possibilities” π Increase business efficiency by 200%. π‘ Save money compared to commercial tools (Free to self-host!) π§ Flexible customization possible
Start automating your daily tasks with the infrastructure you configure today. Your time is already being saved on your first successful workflow run!
> β¨ Recommended next steps: > – Learn advanced nodes from the official documentation > – Set up GitHub integration to notify you when code is pushed > – Implement a workflow to automatically generate daily reports
If you have any questions, please leave a comment. May your IT infrastructure grow with you! π D