How to self-host n8n using Docker

This is the best practice for self-hosting n8n locally.

In the past article I covered the simplest way to self-host n8n — via npm.

However, separating your n8n instance from your local files is a best practice; think of Docker as a computer within your computer. You may want to install files temporarily — Docker facilitates a plug and play approach.

Also, to make your workflows available 24/7, you need to a server-hosted Docker instance. Assuming you won’t keep your laptop / computer on 24/7, you’ll want to learn this step, prior to learning how to launch on platforms, such as AWS, GCP, Azure, Coolify, Digital Ocean, etc.

Installation is super simple. Here are the official docs.

Also here’s the YT Tutorial.

Steps

If you have downloaded Docker, go to Step 3

  1. Download Docker from https://www.docker.com/ — pick the version that matches your computer

  2. Install it > Open the Docker App on Desktop

  3. Docker Hub > Search for n8n

  4. Choose n8nio/n8n > Click “Pull”

  5. Images > Click the “Run” button to start > Expand the dropdown menu of the Optional Setting

  6. Ports: you can input whatever port you like, e.g. 5678, under the host port field > Run

Test a workflow

Let’s see if this works! Use any workflow that has worked for you.

In my case, let’s test my JSON-LD generator workflow — it’s a necessary tool, if you want to improve your chances of appearing on AI searches, such as ChatGPT!
Full YT Tutorial walking you through the n8n workflow.

I need to configure the OpenRouter creds and Google OAuth Client ID to authorize inference to LLM and sending emails, respectively.

Once I configured, it took me about 2 minutes to get the following JSON-LD schema recommendation for my language learning journal website, Llanai.

Conclusion

This is a great tool for those looking to manage costs, while also deploy self-hosted n8n instances for their clients.

This worked great how ever when I run it and attempt to get to localhost:1234 it says connection refused and came up with other errors below and I am not a docker expert so I have no clue how to fix these I usually mostly run self hosted AI models any help would be appreciated thanks!

There are deprecations related to your environment variables. Please take the recommended actions to update your configuration:

- DB_SQLITE_POOL_SIZE → Running SQLite without a pool of read connections is deprecated. Please set `DB_SQLITE_POOL_SIZE` to a value higher than zero. See: https://docs.n8n.io/hosting/configuration/environment-variables/database/#sqlite⁠

  • N8N_RUNNERS_ENABLED → Running n8n without task runners is deprecated. Task runners will be turned on by default in a future version. Please set `N8N_RUNNERS_ENABLED=true` to enable task runners now and avoid potential issues in the future. Learn more: https://docs.n8n.io/hosting/configuration/task-runners/⁠

- N8N_BLOCK_ENV_ACCESS_IN_NODE → The default value of N8N_BLOCK_ENV_ACCESS_IN_NODE will be changed from false to true in a future version. If you need to access environment variables from the Code Node or from expressions, please set N8N_BLOCK_ENV_ACCESS_IN_NODE=false. Learn more: https://docs.n8n.io/hosting/configuration/environment-variables/security/⁠

hello, I am just seeing this now. Just to confirm, did you host locally ? if so, there’s an even simpler way using npm alone - Self-Host n8n for Free - using npm