Hey @headset907,
Great to see that you are learning about Docker. The part I like the most is the docker image file contains all the required things to run the app. Be it n8n, Postgres, or any other software. It takes a big headache away from having to manually fiddle with versioning, dependencies, and other complicated stuff.
Regarding your stack questions.
- If you are not planning to expose n8n to the internet using a domain, you can remove the following environment variables:
N8N_EDITOR_BASE_URL
WEBHOOK_URL
Once they are removed, if you use the webhook node, the URL will default to localhost. These variables are only required if you own a domain and plan to connect something like n8n.example.com
to your instance.
Also, I used two different URLs here in my setup. This is because of an internal process we are running, where I just need to give the Webhook URL to my teammates, as they are only required to send files to that URL. I edit and maintain the n8n instance, so I use n8n.myurl, and my team uses api.myurl in the their apps.
- Yes, please update the time zones according to your local time.
Regarding your question on the node directory.
I used the stack example posted here as a reference to set up my n8n instance. This is taken from n8n’s official repo, which is actively updated (kudos to the team for that). Here, if you notice, they have referenced the internal directory structure as /home/node/.n8n
in line 41 (at the time of this writing). So, we should not touch this part.
However, as you said, I do not have the need to reference local files, so I haven’t mounted any separate folders. Instead, I created a folder called “Files” inside my “/data/n8n/app” directory (Not advisable
) and used that reference inside the workflows I use. So, for example, if your stack has the following volumes:
volumes:
- n8n_storage:/home/node/.n8n
- /home/username/documents:/local/files
you should use the path “/local/files/” inside the workflow nodes instead of “/home/node/.n8n/Files/” to use the local files stored in your laptop.
This is one of the advantages of having a separate directory. You can be assured that you are not messing with the app’s config files.
Just a quick side note:
I see that n8n recommends setting up docker volumes for both the app and the database. Since our requirements differ regarding the backup and other stuff, we had to mount the local directory to the docker instance. This is why you see /data/n8n/app:/home/node/.n8n
in my compose.
Also, for your question on the /init-data.sh
, I’m not an expert in coding and databases, but the primary thing is, Postgres has the option to run custom commands during startup, etc. n8n must be using some commands/custom work to ensure that the database is starting correctly and all the workflows are loaded, when the system restarts or something like that.
The n8n team can best answer this question.