↼ Field Notes

Cover image for Automate Almost Anything with n8n — and Self-Host It with Docker

Automate Almost Anything with n8n — and Self-Host It with Docker

Published 12 November 2026 · 8 min read

If I had to name the one tool that quietly does the most work in my setup, it would be n8n. It is a workflow automation tool — think Zapier or Make, except you can host it yourself, it does not charge you per task, and it can drop down to real code when the drag-and-drop runs out. Behind the scenes, n8n runs the automation for my side projects and my home: it reads incoming order and delivery emails and sends me a short summary on Telegram, routes my server monitoring alerts to the right chat, and watches over everything else — if any workflow fails, one shared error workflow lets me know what broke and where.

In this guide, I’ll walk you through what makes n8n so useful, then spin up an instance with Docker Compose, published through a Cloudflare Tunnel so no ports are open on the server.


🧰 What You’ll Need

  • A Linux server — a small VPS or a home server is fine
  • Docker and Docker Compose installed on it
  • A domain name on Cloudflare (the free tier is enough)

💡 Why n8n

A few things set it apart from the hosted automation tools:

  • Hundreds of built-in integrations — email, Telegram, Google Sheets, GitHub, RSS, databases, and most services you’d want to connect, plus a generic HTTP node for anything with an API.
  • Real triggers, not just polling — workflows can start from a webhook, a schedule, a new email, a form submission, or a chat message.
  • Code when you need it — every workflow can include JavaScript or Python steps, so you are rarely stuck when the built-in nodes fall short.
  • AI built in — there are nodes for the major AI providers and a local model via Ollama, so a workflow can summarise, classify or draft text as one step in a longer chain.
  • Error handling as a feature — you can point every workflow at one shared “error workflow”, so failures alert you instead of dying quietly.
  • Self-hosting is free — the Community edition costs nothing, has no execution limits, and your data stays on your own server. The trade-off is that you maintain it.

Some of the jobs mine does every week:

  • A delivery email lands in a folder → n8n reads it, summarises it with a local LLM, and sends me the short version on Telegram
  • My uptime monitor spots a problem → it calls an n8n webhook → n8n decides who needs to hear about it
  • A scheduled job checks the same things every morning so I don’t have to
  • Any workflow, anywhere, fails → the shared error workflow sends one alert with the workflow name, the node, and the error

⚙️ Step 1: Install Docker and Docker Compose

If your server doesn’t have Docker yet, follow the Docker Engine and Docker Compose installation docs for your distribution first. Verify both are available:

docker --version
docker compose version

⚙️ Step 2: Create a Cloudflare Tunnel

This is the same approach I used to put Cloudron online without opening any ports — a small connector on the server dials out to Cloudflare, and visitors reach your instance through that connection. Nothing listens on your server’s public IP.

In the Cloudflare dashboard:

  1. Go to Networking → Tunnels and select Create a tunnel
  2. Name it something recognisable, like n8n-server01
  3. On the install screen, choose Docker. Cloudflare shows a docker run command — you only need the long token at the end of it, after --token. Copy that and keep it somewhere safe: treat it like a password, because anyone holding it can run your tunnel
  4. Add a Published application route: hostname n8n.example.com (your subdomain and domain), service http://n8n:5678

The service address uses n8n because that is the name the Compose file below gives the container — the tunnel connector will sit on the same Docker network and reach it by that name. Cloudflare creates the DNS record for the hostname automatically.


⚙️ Step 3: Create the Project and Its .env File

Create a project directory to hold the configuration:

mkdir n8n-compose
cd n8n-compose

Inside it, create an .env file and change the values to match your own:

# DOMAIN_NAME and SUBDOMAIN together determine where n8n will be reachable from
# The top level domain to serve from
DOMAIN_NAME=example.com
# The subdomain to serve from
SUBDOMAIN=n8n
# The above example serves n8n at: https://n8n.example.com

# Optional timezone, used by the Cron and other scheduling nodes
# New York is the default value if not set
GENERIC_TIMEZONE=Asia/Singapore

# The tunnel token from Step 2 — keep this file private
TUNNEL_TOKEN=eyJ...

⚙️ Step 4: Create the Local Files Directory

n8n can share a folder with the host, which the Read/Write Files from Disk node uses:

mkdir local-files

The Compose file below can create this directory on its own, but making it manually ensures it gets the right ownership and permissions.


⚙️ Step 5: Create the Docker Compose File

Create a compose.yaml file in the same directory and paste in the following:

services:
  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: always
    ports:
      - "127.0.0.1:5678:5678"
    environment:
      - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
      - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - N8N_RUNNERS_ENABLED=true
      - NODE_ENV=production
      - WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
      - TZ=${GENERIC_TIMEZONE}
    volumes:
      - n8n_data:/home/node/.n8n
      - ./local-files:/files

  cloudflared:
    image: cloudflare/cloudflared:latest
    restart: always
    command: tunnel --no-autoupdate run
    environment:
      - TUNNEL_TOKEN=${TUNNEL_TOKEN}
    depends_on:
      - n8n

volumes:
  n8n_data:

This starts two containers. The first is n8n itself; its one port mapping is bound to 127.0.0.1, so it is reachable from the server itself but not from the internet. The second is cloudflared, the tunnel connector: it dials out to Cloudflare and forwards traffic for your hostname to http://n8n:5678 over the Docker network. HTTPS is handled at Cloudflare’s edge, so there are no certificates to manage on the server.

The token goes in through an environment variable rather than on the command line, so it doesn’t show up in docker ps output.

One volume matters here:

Name Container mount What it holds
n8n_data /home/node/.n8n n8n’s database and encryption key

The ./local-files folder is mounted at /files inside n8n.


⚙️ Step 6: Start It Up

sudo docker compose up -d

Give it a minute, then open https://n8n.example.com in your browser and create the owner account. In the Cloudflare dashboard, the tunnel should now show as Healthy.

If the page doesn’t load, check the connector’s logs — a healthy one shows four registered connections:

sudo docker compose logs cloudflared

To stop the containers later:

sudo docker compose stop

🔒 Worth Doing Once It’s Running

  • Back up the n8n_data volume. It holds the database and the encryption key for every credential you save. Lose the key and your saved logins are unrecoverable, even from a database backup.
  • Keep it updated. n8n releases often. Updating is two commands — docker compose pull then docker compose up -d — or you can let a tool like Watchtower pull new images automatically.
  • Treat it like a master key. An n8n instance accumulates logins to your email, chat apps and servers. Use a strong owner password, and don’t share the instance. If you want a login screen in front of it as well, Cloudflare Access can sit on the same hostname.
  • The default SQLite database is fine for personal use. If you grow into heavy volume, the same Compose pattern extends to PostgreSQL.

☁️ Option 1: Let n8n Host It for You

Self-hosting isn’t for everyone — n8n itself recommends its managed service, n8n Cloud, if you don’t want to maintain a server. You sign up, and your instance just runs: updates, backups and uptime are their problem. Cloud plans are priced by workflow executions:

Plan Price (billed annually) Executions / month Hosting
Starter €20 / month 2,500 n8n Cloud
Pro €50 / month 10,000 n8n Cloud
Community Free Unlimited Your server

Prices checked on n8n.io in November 2026, in euros and excluding tax; monthly billing costs more (€24 and €60). There’s a free trial if you want to try before paying. Check the pricing page before treating these figures as final.

For most people starting out, this is the option I’d recommend — you can always self-host later and export your workflows.


🛠️ Option 2: Have It Set Up for You

If you’d rather run your own instance but don’t want to do the server work, I can set the Docker install from this guide up for you — on your VPS or home server, behind a Cloudflare Tunnel on your own domain, with the basics above in place — for a small fee. Email me at hello@alwynsoh.com, or message me on Ko-fi, and we’ll work out the details.


✅ Which Should You Choose?

Your situation My recommendation
You want it working today, with nothing to maintain n8n Cloud (Starter)
You’re comfortable with Docker and want no usage limits Self-host with this guide
You want your own instance, but not the setup work The setup service above
Your workflows will run thousands of times a month Self-host — cloud execution pricing adds up

📝 Summary

n8n is the rare automation tool that is free to self-host, unlimited in what it can run, and still approachable — and once it is running, it tends to spread: one workflow becomes ten. Spin it up with Docker Compose behind a Cloudflare Tunnel in about fifteen minutes, let n8n Cloud carry it if you’d rather not maintain a server, or have it set up for you.

If this guide helped you, consider buying me a coffee:

👉 https://ko-fi.com/alwynsoh

Every tip helps me keep testing, writing, and sharing guides like this. Appreciate the support!


Related posts