This project provides configuration files to easily start and manage n8n using Docker Compose. It also includes a Makefile to simplify exporting and importing workflows and credentials.
- Docker
- Docker Compose
-
Prepare Configuration File: Create a file named
configin the root of the repository with the following content:{ "encryptionKey": "YOUR_VERY_SECRET_ENCRYPTION_KEY" }Replace
YOUR_VERY_SECRET_ENCRYPTION_KEYwith your actual secret key for encrypting n8n credentials. This key will be set as theN8N_ENCRYPTION_KEYenvironment variable indocker-compose.yaml. -
Create Data Directories: Create directories to store exported workflows and credentials.
mkdir -p workflows credentials
These directories are mounted to
/home/node/workflowsand/home/node/credentialsin the container viadocker-compose.yaml.
Use the commands defined in the Makefile to operate n8n.
-
Start n8n:
make up
n8n will be accessible at
http://localhost:5678. -
Stop n8n:
make down
-
View Logs:
make logs
-
Export Workflows: Exports all workflows to the
./workflows/directory. (Individual files will be generated if multiple workflows exist).make export-workflows
-
Import Workflows: Imports workflows from
./workflows/workflows.json. If you exported multiple workflow files, you may need to rename the desired file toworkflows.jsonor merge them.make import-workflows
-
Export Credentials: Exports all credentials to the
./credentials/directory. (Individual files will be generated if multiple credentials exist).make export-credentials
-
Import Credentials: Imports credentials from
./credentials/credentials.json. If you exported multiple credential files, you may need to rename the desired file tocredentials.jsonor merge them.make import-credentials
Caution: Import commands may overwrite existing data. Use with care.
The N8N_ENCRYPTION_KEY environment variable is set in the docker-compose.yaml file.
For security, it is recommended to use an .env file for this key and add .env to your .gitignore instead of writing the key directly into docker-compose.yaml.
Example .env file:
N8N_ENCRYPTION_KEY=YOUR_VERY_SECRET_ENCRYPTION_KEY
Changes in docker-compose.yaml:
services:
n8n:
# ...
environment:
- N8N_ENCRYPTION_KEY=${N8N_ENCRYPTION_KEY} # Modified to read from .env file
# ...If necessary, enable the commented-out timezone settings in the docker-compose.yaml file.
environment:
- N8N_ENCRYPTION_KEY=o9C/a9AQ8mZ/hoSTkjbSiW5Bx3B4Gm/1
# Set GENERIC_TIMEZONE and TZ to specify the timezone
- GENERIC_TIMEZONE=Asia/Tokyo # Example: Japan Standard Time
- TZ=Asia/Tokyo # Example: Japan Standard Time.
├── Makefile # Makefile for n8n operations
├── config # n8n configuration file (e.g., encryption key)
├── credentials/ # Exported credentials (credentials.json)
├── docker-compose.yaml # Docker Compose configuration file
├── workflows/ # Exported workflows (workflows.json)
├── README.md # This file (English)
└── README_ja.md # Japanese version of README