Docker-Compose#
These instructions cover how to run n8n on a Linux server using Docker Compose.
If you have already installed Docker and Docker-Compose, then you can start with step 3.
You can find Docker Compose configurations for various architectures in the n8n-hosting repository.
Self-hosting knowledge prerequisites
Self-hosting n8n requires technical knowledge, including:
- Setting up and configuring servers and containers
- Managing application resources and scaling
- Securing servers and applications
- Configuring n8n
n8n recommends self-hosting for expert users. Mistakes can lead to data loss, security issues, and downtime. If you aren't experienced at managing servers, n8n recommends n8n Cloud.
Latest and Next versions
n8n releases a new minor version most weeks. The latest
version is for production use. next
is the most recent release. You should treat next
as a beta: it may be unstable. To report issues, use the forum.
Current latest
: 1.107.4
Current next
: 1.108.1
1. Install Docker and Docker Compose#
The way that you install Docker and Docker Compose depends on your Linux distribution. You can find specific instructions for each component in the links below:
After following the installation instructions, verify that Docker and Docker Compose are available by typing:
1 2 |
|
2. Optional: Non-root user access#
You can optionally grant access to run Docker without the sudo
command.
To grant access to the user that you're currently logged in with (assuming they have sudo
access), run:
1 2 3 |
|
To grant access to a different user, type the following, substituting <USER_TO_RUN_DOCKER>
with the appropriate username:
1 |
|
You will need to run exec sg docker newgrp
from any of that user's existing sessions for it to access the new group permissions.
You can verify that your current session recognizes the docker
group by typing:
1 |
|
3. DNS setup#
To host n8n online or on a network, create a dedicated subdomain pointed at your server.
Add an A record to route the subdomain accordingly:
Record type | Name | Destination |
---|---|---|
A | n8n (or your desired subdomain) |
<your_server_IP_address> |
4. Create an .env
file#
Create a project directory to store your n8n environment configuration and Docker Compose files and navigate inside:
1 2 |
|
Inside the n8n-compose
directory, create an .env
file to customize your n8n instance's details. Change it to match your own information:
.env file | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
5. Create local files directory#
Inside your project directory, create a directory called local-files
for sharing files between the n8n instance and the host system (for example, using the Read/Write Files from Disk node):
1 |
|
The Docker Compose file below can automatically create this directory, but doing it manually ensures that it's created with the right ownership and permissions.
6. Create Docker Compose file#
Create a compose.yaml
file. Paste the following in the file:
compose.yaml file | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|
The Docker Compose file above configures two containers: one for n8n, and one to run traefik, an application proxy to manage TLS/SSL certificates and handle routing.
It also creates and mounts two Docker Volumes and mounts the local-files
directory you created earlier:
Name | Type | Container mount | Description |
---|---|---|---|
n8n_data |
Volume | /home/node/.n8n |
Where n8n saves its SQLite database file and encryption key. |
traefik_data |
Volume | /letsencrypt |
Where traefik saves TLS/SSL certificate data. |
./local-files |
Bind | /files |
A local directory shared between the n8n instance and host. In n8n, use the /files path to read from and write to this directory. |
7. Start Docker Compose#
Start n8n by typing:
1 |
|
To stop the containers, type:
1 |
|
8. Done#
You can now reach n8n using the subdomain + domain combination you defined in your .env
file configuration. The above example would result in https://n8n.example.com
.
n8n is only accessible using secure HTTPS, not over plain HTTP.
If you have trouble reaching your instance, check your server's firewall settings and your DNS configuration.
Next steps#
- Learn more about configuring and scaling n8n.
- Or explore using n8n: try the Quickstarts.