Docker-Compose#
If you have already installed Docker and Docker-Compose, then you can start with step 4.
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.52.2
Current next
: 1.53.1
1. Install Docker#
This can vary depending on the Linux distribution used. You can find detailed instructions in the Docker documentation. The following example is for Ubuntu:
1 2 3 4 5 6 7 8 9 |
|
2. Optional: Non-root user access#
Run when logged in as the user that should also be allowed to run docker:
1 2 |
|
3. Install Docker-Compose#
This can vary depending on the Linux distribution used. You can find detailed instructions in the Docker documentation.
The example below is for Ubuntu:
1 |
|
4. DNS setup#
Add A record to route the subdomain accordingly:
1 2 3 |
|
5. Create Docker Compose file#
Create a docker-compose.yml
file. Paste the following in the 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 60 |
|
If you are planning on reading/writing local files with n8n (for example, by using the Read/Write Files from Disk node, you will need to configure a data directory for those files here. If you are running n8n as a root user, add this under volumes
for the n8n service:
1 |
|
If you are running n8n as a non-root user, add this under volumes
for the n8n service:
1 |
|
You will now be able to write files to the /files
directory in n8n and they will appear on your server in either /local-files
or /home/<YOUR USERNAME>/n8n-local-files
, respectively.
6. Create .env
file#
Create an .env
file and change it accordingly.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
7. Create data folder#
Create the Docker volume that's defined as n8n_data
. n8n will save the database file from SQLite and the encryption key in this volume.
1 |
|
Create a volume for the Traefik data, This is defined as traefik_data
.
1 |
|
8. Start Docker Compose#
n8n can now be started via:
1 |
|
To stop the container:
1 |
|
9. Done#
n8n will now be reachable using the above defined subdomain + domain combination.
The above example would result in: https://n8n.example.com
n8n will only be reachable using https
and not using http
.
Secure your n8n instance
Make sure that you set up authentication for your n8n instance.
Next steps#
- Learn more about configuring and scaling n8n.
- Or explore using n8n: try the Quickstarts.