Docker, n8n and OpenClaw: a local stack for automation
We put a workshop for automation on your own computer: Docker as the "box" for programs, n8n for workflows, Qdrant as a memory for documents and — separately — OpenClaw, a personal AI assistant. The whole thing starts with one command, docker compose up -d, and the secrets live in a separate file.
openclaw/openclaw with variables such as WEBUI_SECRET_KEY and OLLAMA_BASE_URL — those are settings of a different project (Open WebUI). Today OpenClaw is an open-source personal AI assistant with a Gateway that connects to chat apps (Telegram, WhatsApp, Discord…) and has its own dashboard; Docker is optional for it. So we removed it from the shared compose file and gave it a separate step based on the official documentation. The compose file was reworked: the obsolete version: line is gone; Redis and n8n queue mode are gone (queue mode needs a separate worker and is needless complexity on one machine); N8N_BASIC_AUTH_ACTIVE is gone (n8n basic auth has not existed since version 1.0) and so is N8N_HOST=0.0.0.0 (that variable is a host name, not a listen address); instead of latest, versions are pinned in .env (n8n 2.41.4, Qdrant 1.19.1, Postgres 18); passwords and the encryption key are no longer in the text but generated; data lives in named volumes, because Qdrant warns about data loss with Windows folders under WSL; ports open only on 127.0.0.1 and Postgres is not published at all. We added Docker Desktop 4.93 and the WSL ≥ 2.1.5 requirement, backups, updating, and the warning about Ollama on WSL2. The manual netsh portproxy setup is gone — Docker Desktop publishes ports itself. Also removed: the two-machine section (Machine A/B) and the "AI Clone" system prompt for OpenClaw (that was an Open WebUI setting).
01What you'll learn
- Why containers are convenient and how Docker Desktop runs on top of WSL2.
- How to describe a whole stack in one
compose.yamlfile and keep the secrets in.env. - How to start n8n with Postgres and Qdrant and check that they are alive.
- How a container reaches Ollama on your machine — and why
localhostdoes not work. - How to build a first workflow with a local model and a first collection in a vector database.
- What OpenClaw really is, how to install it and with what care to run it.
- How to back up your data and update safely.
02Before you start
- You have done Lesson 1 (Ubuntu 24.04 on WSL2) and Lesson 2 (Ollama 🔒 local with
qwen2.5:7bandnomic-embed-textpulled). - Windows 10 (22H2) or Windows 11 (23H2 or newer) — Pro, Enterprise or Education; Home also runs Linux containers. Virtualization must be enabled in BIOS/UEFI.
- WSL version 2.1.5 or newer (check with
wsl --version) and at least 8 GB of RAM (Docker's requirement; with an Ollama model loaded you need more). - Licence: Docker Desktop is free for personal use and small businesses; companies with more than 250 employees or more than 10 million USD in revenue need a paid subscription. The alternative is Docker Engine installed directly in Ubuntu — but not both at once.
- For OpenClaw (below): Node.js 24.16+ or 26.1+, unless you run it through Docker.
~/kagami) must be inside Ubuntu, not under /mnt/c/…. Docker says so explicitly: across the Windows ↔ Linux boundary folders are slow and cause permission errors.03Steps
-
What will live where
At the end you will have three containers in one project (n8n, Postgres, Qdrant), Ollama from the previous lesson on the host machine and — separately — OpenClaw. Why containers? Because each program arrives with everything it needs, does not get in the way of the others and is removed with one command, leaving no mess behind.
Service What it is for Address from Windows n8n Editor and engine for automations http://localhost:5678Qdrant Vector database — a memory of documents for RAG http://localhost:6333/dashboardPostgres The n8n database (inside Docker only) not opened to the outside Ollama The models from Lesson 2 (outside Docker) http://localhost:11434OpenClaw Personal AI assistant with a Gateway (separate step) depends on the install — see step 8 The ports are each product's defaults — see its documentation if one is taken on your machine.
-
Docker Desktop with WSL2
Download the installer from docs.docker.com (the recommended per-user install needs no administrator rights). If Ubuntu already has a separate Docker Engine, remove it first — the two get in each other's way. On first launch accept turning on WSL 2. Then: Settings → Resources → WSL Integration → enable Ubuntu-24.04 → Apply.
⚠️Without integration the commands will not exist in UbuntuThedockercommand works from a Windows terminal even without it, but to call it in the Ubuntu terminal (where we keep the project) the integration must be on. If the option is missing, Docker may be in "Windows containers" mode — from the tray icon choose Switch to Linux containers.bash · in Ubuntu (WSL2)docker --version docker compose version docker run --rm hello-worldThe third command pulls a tiny image and prints a greeting. If you see "Hello from Docker!", the engine works. The command is
docker compose(with a space) — Compose v2; the old hyphenateddocker-composeis obsolete. -
The folder and the file with the secrets
Secrets (passwords, the encryption key) do not go into the compose file. We keep them in
.env— Compose reads it by itself. We generate them on the spot so that no two installs share the same "secret".bash · ~/kagami/.envmkdir -p ~/kagami && cd ~/kagami cat > .env <<EOF N8N_VERSION=2.41.4 QDRANT_VERSION=v1.19.1 POSTGRES_USER=n8n POSTGRES_PASSWORD=$(openssl rand -hex 24) POSTGRES_DB=n8n N8N_ENCRYPTION_KEY=$(openssl rand -hex 32) TZ=Europe/Sofia EOF chmod 600 .env✅Keep the key outside the stackN8N_ENCRYPTION_KEYencrypts all your connections in n8n. Without it, after a restore from backup, the saved credentials cannot be decrypted. Copy it into a password manager. The versions (2.41.4,v1.19.1) are the current stable ones as of 01.10.2026 — see "Updating" below. -
The compose.yaml file
One file describes the whole stack. Four rules in it are worth remembering: versions are pinned (not
latest), data lives in named volumes, ports bind only to127.0.0.1(not reachable from the network), and n8n waits for Postgres to be "healthy" before it starts.yaml · ~/kagami/compose.yamlname: kagami services: postgres: image: postgres:18 restart: unless-stopped environment: POSTGRES_USER: ${POSTGRES_USER} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_DB: ${POSTGRES_DB} PGDATA: /var/lib/postgresql/data volumes: - db_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -h localhost -U ${POSTGRES_USER} -d ${POSTGRES_DB}"] interval: 5s timeout: 5s retries: 10 qdrant: image: qdrant/qdrant:${QDRANT_VERSION} restart: unless-stopped ports: - "127.0.0.1:6333:6333" - "127.0.0.1:6334:6334" volumes: - qdrant_data:/qdrant/storage n8n: image: docker.n8n.io/n8nio/n8n:${N8N_VERSION} restart: unless-stopped depends_on: postgres: condition: service_healthy environment: TZ: ${TZ} GENERIC_TIMEZONE: ${TZ} DB_TYPE: postgresdb DB_POSTGRESDB_HOST: postgres DB_POSTGRESDB_PORT: "5432" DB_POSTGRESDB_DATABASE: ${POSTGRES_DB} DB_POSTGRESDB_USER: ${POSTGRES_USER} DB_POSTGRESDB_PASSWORD: ${POSTGRES_PASSWORD} N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY} N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS: "true" ports: - "127.0.0.1:5678:5678" volumes: - n8n_data:/home/node/.n8n extra_hosts: - "host.docker.internal:host-gateway" volumes: db_data: qdrant_data: n8n_data:💡Why exactly this wayPGDATA — Postgres 18 changed its default data location; without this line the database comes back empty whenever the container is recreated. Volumes, not folders — Qdrant documents that a Windows folder mounted into a container under WSL is not fully compatible and puts data at risk. 127.0.0.1 — the port is not visible to others on your network; Postgres has no published port at all, n8n finds it by the namepostgres. extra_hosts — the namehost.docker.internalpoints to the host machine; Docker Desktop provides it itself, and this line guarantees it on other engines.Check that the file is readable (Compose substitutes the variables and prints the result — secrets included, so do not send it to anyone):
bashdocker compose config --quiet && echo "compose: OK" -
Start it and check
bashcd ~/kagami docker compose up -d docker compose psThe first time, the images are downloaded — it needs a few minutes and an internet connection. After that,
docker compose psshould showpostgresashealthyandn8nandqdrantasrunning. A second check — do they answer:bashcurl -sf http://localhost:5678/healthz && echo " n8n is alive" curl -s http://localhost:6333/collectionsThe second command returns
{"result":{"collections":[]},…}— an empty list, you have no collections yet. If something is not standing, look at the logs:docker compose logs -f n8n(exit withCtrl+C). -
n8n: first login and the link to Ollama
Open
http://localhost:5678in the browser. On the first visit n8n makes you create an owner account (email, name, password) — there is no other "basic authentication". The account is local, in your own database.Now the container must reach Ollama, which runs outside Docker. Inside a container
localhostis the container itself, so we usehost.docker.internal. Check from the container:bashdocker compose exec n8n wget -qO- http://host.docker.internal:11434/api/tagsYou should see JSON with a list of models (
qwen2.5:7b…). Then in n8n: Credentials → Create credential → Ollama → Base URLhttp://host.docker.internal:11434→ Save.⚠️Does not reach Ollama?(1) In Lesson 2 we left Ollama listening on loopback only — that is safer. If the container cannot reach it, setEnvironment="OLLAMA_HOST=0.0.0.0:11434"in the service override (sudo systemctl edit ollama) and restart; the model is then reachable from your network — close the port in the firewall for everyone but your own machine. (2) That Ollama runs in WSL2 while the container talks to the Windows host works through WSL port forwarding — we have not tested it; if it fails, the simplest fix is Ollama for Windows on the host, or Ollama inside the compose project. (3) The address has no/v1— Ollama is spoken to through its own native API.First workflow. Workflows → Create workflow → add a Manual Trigger → Basic LLM Chain (prompt set to "Define below": Say "The stack works!" in 3 languages) → attach to it the sub-node Ollama Chat Model with your credential and model
qwen2.5:7b. Press Execute workflow. The answer appears in the chain's output (thetextfield — check the Output panel) in about ten seconds on a CPU, faster with a graphics card. If you want to carry it on, add an "Edit Fields (Set)" node and take{{ $json.text }}.🧪Why Postgres is not a credential hereThe old lesson also added n8n's Postgres as a "credential". That is the database in which n8n keeps itself. For your own data create a separate database and a separate user — do not mix them. -
Qdrant: the first collection
Qdrant is the vector database — the "fingerprints" (embeddings) of your documents for RAG will live here. The collection's vector size must be exactly the output size of the embedding model. For
nomic-embed-textit is 768; check it on your machine — the length of the array in Ollama's answer:bashcurl -s http://localhost:11434/api/embed \ -d '{"model":"nomic-embed-text","input":"test"}' | python3 -c "import sys,json; print(len(json.load(sys.stdin)['embeddings'][0]))"bash · create a collectioncurl -X PUT http://localhost:6333/collections/kagami_kb \ -H "Content-Type: application/json" \ -d '{"vectors": {"size": 768, "distance": "Cosine"}}' curl -s http://localhost:6333/collections/kagami_kbThe first command returns
{"result":true,"status":"ok",…}. Also look at the dashboard athttp://localhost:6333/dashboard. The number 768 is right fornomic-embed-textper our dimension check; if you change the model you change the size too — a collection with the "wrong" size simply refuses the writes. -
OpenClaw: what it is and how to install it
⚠️OpenClaw is not a chat window for OllamaOpenClaw is an open-source personal AI assistant: one "Gateway" process runs on your machine, connects to a model (local through Ollama, or a cloud one) and to chat apps such as Telegram, WhatsApp or Discord, and its dashboard lives in the browser. It can have tools — a browser, command execution, web search. That makes it useful, but also risky: run it with care.Option A — the standard one (recommended): the official installer. You need Node.js 24.16+ or 26.1+. Read the script before you run it — do not pipe something from the internet into your terminal blindly.
bash · Ubuntu (WSL2) or macOS/Linuxcurl -fsSL https://openclaw.ai/install.sh | bashPowerShell · native Windowsiwr -useb https://openclaw.ai/install.ps1 | iexThe installer starts the guided helper (onboarding). Choose Quick start — it looks for AI access you already have (a Claude Code or Codex CLI login, or a provider key) and opens the dashboard. Then you leave it running as a service:
bashopenclaw gateway install openclaw gateway status openclaw dashboardThe second should show that the Gateway is listening; the third opens the dashboard — if it loads, all is well. If something goes wrong,
openclaw triageruns a read-only check and prepares a diagnosis.With a local model through Ollama: run
openclaw onboard, choose Ollama → Local only and Ollama's address. Then check:openclaw models list --provider ollama. The address has no/v1— OpenClaw talks to Ollama's native API, and with/v1tool calling breaks. Automatic discovery only takes eligible models already loaded in memory, not every installed one; for an idle model choose Choose connection → Local only. ⚠️ We have not verified the exact eligibility rules (tool support, minimum context) — see the Ollama page in the documentation.Option B — in Docker (optional): the documentation describes it as a way to get an isolated, throwaway environment. You clone the repository github.com/openclaw/openclaw and from its root run
./scripts/docker/setup.sh— the script builds an image, runs onboarding, writes the generated Gateway key to.envand starts the service through Compose. The dashboard opens locally and you paste the key into Settings. Ready-made images exist on GHCR (ghcr.io/openclaw/openclaw) and Docker Hub; for lasting use pin a specific version, not "latest". For a container that talks to Ollama on the host the same rule applies: notlocalhost.⛔An assistant with tools = real consequencesBefore you connect it to chats: runopenclaw security auditand review the result; allow only people you know to message it (the "pairing" mode is the default); do not expose it to the internet without protection. For actions with real effect the rule from Block 3 still stands: human approval. The commands in this step follow the official documentation as of 01.10.2026 and have not been run by us. -
Everyday commands, backups and updating
bash · from ~/kagamidocker compose up -d # start everything docker compose ps # status docker compose logs -f n8n # n8n logs (Ctrl+C to exit) docker compose restart n8n # restart n8n only docker compose down # stop; data stays in the volumes docker stats --no-stream # CPU and memoryBackup. A full backup has two parts: the database and the encryption key. The key is already in
.env— copy that file somewhere safe too.bash · backupmkdir -p backups docker compose exec -T postgres sh -c 'pg_dump -U "$POSTGRES_USER" "$POSTGRES_DB"' > backups/n8n-db-$(date +%Y%m%d).sql docker compose exec n8n n8n export:workflow --backup --output=/home/node/.n8n/backups/ docker compose cp n8n:/home/node/.n8n/backups ./backups/workflowsUpdating. Change the number in
.env(N8N_VERSION,QDRANT_VERSION) to the current releases of n8n and Qdrant, then:bashdocker compose pull docker compose up -d⚠️Postgres is not upgraded by changing a numberA jump between major versions does not open the old data. Keep the imagepostgres:18, and for a major jump first runpg_dumpand follow the official PostgreSQL guide. Before every n8n update — take a backup. -
When something does not work
❌n8n does not start — connection to PostgresPostgres's healthcheck has not passed yet. Wait half a minute and look atdocker compose logs postgres | tail -20; thendocker compose restart n8n. If you changed the user or password in.envafter the first run, the database keeps the old ones — either put the old values back, or delete the database volume only in a test setup (docker compose down -vdeletes all volumes!).❌n8n or OpenClaw cannot see the Ollama modelsCheck withdocker compose exec n8n wget -qO- http://host.docker.internal:11434/api/tags. If refused: Ollama listens only on loopback (OLLAMA_HOST, Lesson 2), a firewall, or the address containslocalhost//v1.❌localhost:5678 does not open from WindowsFirst look atdocker compose ps— is the container running? Thencurl -sf http://localhost:5678/healthzin Ubuntu. If it works there but not in the browser, restart WSL: in PowerShellwsl --shutdown, then start Docker Desktop. Manual port forwarding is not needed.❌WSL2 keeps rebooting once Ollama startsOpenClaw's documentation describes a known problem on WSL2 with NVIDIA: theollama.serviceunit withRestart=alwaysloads a model at startup and Windows kills the virtual machine in a loop. Fix:sudo systemctl disable ollamaand start Ollama by hand, or in%USERPROFILE%\.wslconfigadd the lineautoMemoryReclaim=disabledunder[experimental], thenwsl --shutdown.🔐Do not open the stack to the internet "just like that"Everything here is bound to127.0.0.1on purpose. For access from outside you need HTTPS, a reverse proxy and separate security work. n8n's documentation recommends external "task runners" for the code in nodes in production — in our local stack it is the internal mode, acceptable only on a machine with no other users.
04Check
Checklist
docker compose versionshows v2.x andhello-worldruns.- The project folder is inside the Ubuntu file system, not under
/mnt/c. .envexists with generated secrets, permissions 600, and the key is copied somewhere safe.docker compose config --quietgives no error;docker compose psshowspostgreshealthy andn8nandqdrantrunning.- n8n's
/healthzanswers; the owner account is created. - The container sees Ollama through
host.docker.internal; the test workflow returns an answer. - The Qdrant collection has the same size as the embedding model.
- OpenClaw:
openclaw gateway statusis fine, the dashboard opens,openclaw security audithas been run. - You have a backup of the database and of the workflows.
Quiz
1. From the n8n container you want to reach Ollama on your machine. Which address do you use?
2. Why is Qdrant's data in a named volume rather than a Windows folder?
3. Where is the right place for the database password and the n8n encryption key?
4. What is OpenClaw?
05What's next
06Sources
- n8n: install using Docker Compose — Compose v2, the WSL note, Postgres.
- n8n: install with Docker — timezone, stable and beta versions.
- n8n-hosting: Compose with Postgres — the
docker.n8n.io/n8nio/n8nimage, Postgres 18 PGDATA. - n8n: environment variables —
N8N_ENCRYPTION_KEY,N8N_HOST; also: backup and restore and task runners. - Docker Desktop for Windows — requirements, licence; WSL 2 backend; release notes.
- Qdrant: quickstart and requirements — ports, named volumes on Windows.
- OpenClaw: getting started · Docker install · Ollama provider · security.
- nomic-embed-text on Ollama 🔒 local — the embedding model.