The KAGAMI mark КАГАМИ
kagami.bg/academy · lesson · machine-readable viewVERIFIED 2026-10-01 · UPDATED 2026-10-01
IDENTITY
module
DevStation-03 · Docker, n8n and OpenClaw
series
DevStation · lesson 3 of 6
level
Intermediate
duration
1–2 h
prerequisites
DevStation 1 (Ubuntu on WSL2) and 2 (Ollama with a pulled chat model and an embedding model)
trust_label
VERIFIED 2026-10-01 (against official n8n, Docker, Qdrant and OpenClaw documentation; image tags checked on Docker Hub; compose file parsed as valid YAML) · UPDATED 2026-10-01 · NOT TESTED end to end (no Docker daemon available during the check)
versions
Docker Desktop 4.93.x · Docker Compose v2 (plugin) · n8n 2.41.x stable (pinned via env) · PostgreSQL 18 · Qdrant 1.19.x (pinned via env) · OpenClaw release-tagged images (e.g. 2026.9.x) · WSL ≥ 2.1.5
language
human view: en · bulgarian edition: /academy/devstation/ (lesson 3)
previous / next
DevStation 02 · Ollama and AI models / DevStation 04 · Canva Connect API with n8n
PURPOSE

Run a local automation stack on a Windows machine with WSL2: Docker Desktop as the container engine, one Compose project with n8n (workflow automation) on PostgreSQL and Qdrant (vector database), secrets kept in an .env file, services published to loopback only. Connect n8n to a host-side Ollama. Install OpenClaw separately, because it is a personal AI assistant with a Gateway, not a web chat front end for Ollama.

KEY CONCEPTS
COMMANDS / PATHS
CHECKLIST
NEXT MODULE

DevStation 04 · Canva API designs · connect n8n to the Canva Connect API for template-based social media designs · offer: Quick experiment (kagami.bg/stalbata/)

SOURCES
TAGS
dockerdocker-composewsl2n8npostgresqdrantopenclawollamaself-hosting
VERIFIED · 01.10.2026 UPDATED · 01.10.2026

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.

⏱ 1–2 h Intermediate DevStation · Lesson 3/6 Docker · n8n · Qdrant · OpenClaw
Docker Desktop · Compose🔒 local n8n · Postgres · Qdrant🔒 local Ollama (the model)🔒 local OpenClaw with a local model🔒 local OpenClaw with a cloud model (optional)🌐 global
🔄
UPDATED · 01.10.2026 — what changed
OpenClaw was described wrongly. The old version called it an "OpenWebUI-based chat" for Ollama, in an image 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).
⚠️
What we have not run ourselves
We had no Docker available during the check. The files are checked against the official docs and are syntactically valid, but they are not tested end to end — that is why there is no "TESTED" label. Least verified are the container → Ollama link on WSL2 and the OpenClaw commands.

01What you'll learn

02Before you start

⛔
Work inside the WSL file system
The project folder (~/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

  1. 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.

    ServiceWhat it is forAddress from Windows
    n8nEditor and engine for automationshttp://localhost:5678
    QdrantVector database — a memory of documents for RAGhttp://localhost:6333/dashboard
    PostgresThe n8n database (inside Docker only)not opened to the outside
    OllamaThe models from Lesson 2 (outside Docker)http://localhost:11434
    OpenClawPersonal 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.

  2. 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 Ubuntu
    The docker command 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-world

    The 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 hyphenated docker-compose is obsolete.

  3. 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/.env
    mkdir -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 stack
    N8N_ENCRYPTION_KEY encrypts 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.
  4. 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 to 127.0.0.1 (not reachable from the network), and n8n waits for Postgres to be "healthy" before it starts.

    yaml · ~/kagami/compose.yaml
    name: 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 way
    PGDATA — 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 name postgres. extra_hosts — the name host.docker.internal points 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):

    bash
    docker compose config --quiet && echo "compose: OK"
  5. Start it and check

    bash
    cd ~/kagami
    docker compose up -d
    docker compose ps

    The first time, the images are downloaded — it needs a few minutes and an internet connection. After that, docker compose ps should show postgres as healthy and n8n and qdrant as running. A second check — do they answer:

    bash
    curl -sf http://localhost:5678/healthz && echo " n8n is alive"
    curl -s http://localhost:6333/collections

    The 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 with Ctrl+C).

  6. n8n: first login and the link to Ollama

    Open http://localhost:5678 in 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 localhost is the container itself, so we use host.docker.internal. Check from the container:

    bash
    docker compose exec n8n wget -qO- http://host.docker.internal:11434/api/tags

    You should see JSON with a list of models (qwen2.5:7b…). Then in n8n: Credentials → Create credential → Ollama → Base URL http://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, set Environment="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 (the text field — 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 here
    The 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.
  7. 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-text it is 768; check it on your machine — the length of the array in Ollama's answer:

    bash
    curl -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 collection
    curl -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_kb

    The first command returns {"result":true,"status":"ok",…}. Also look at the dashboard at http://localhost:6333/dashboard. The number 768 is right for nomic-embed-text per our dimension check; if you change the model you change the size too — a collection with the "wrong" size simply refuses the writes.

  8. OpenClaw: what it is and how to install it

    ⚠️
    OpenClaw is not a chat window for Ollama
    OpenClaw 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/Linux
    curl -fsSL https://openclaw.ai/install.sh | bash
    PowerShell · native Windows
    iwr -useb https://openclaw.ai/install.ps1 | iex

    The 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:

    bash
    openclaw gateway install
    openclaw gateway status
    openclaw dashboard

    The second should show that the Gateway is listening; the third opens the dashboard — if it loads, all is well. If something goes wrong, openclaw triage runs 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 /v1 tool 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 .env and 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: not localhost.

    ⛔
    An assistant with tools = real consequences
    Before you connect it to chats: run openclaw security audit and 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.
  9. Everyday commands, backups and updating

    bash · from ~/kagami
    docker 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 memory

    Backup. 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 · backup
    mkdir -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/workflows

    Updating. Change the number in .env (N8N_VERSION, QDRANT_VERSION) to the current releases of n8n and Qdrant, then:

    bash
    docker compose pull
    docker compose up -d
    ⚠️
    Postgres is not upgraded by changing a number
    A jump between major versions does not open the old data. Keep the image postgres:18, and for a major jump first run pg_dump and follow the official PostgreSQL guide. Before every n8n update — take a backup.
  10. When something does not work

    ❌
    n8n does not start — connection to Postgres
    Postgres's healthcheck has not passed yet. Wait half a minute and look at docker compose logs postgres | tail -20; then docker compose restart n8n. If you changed the user or password in .env after 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 -v deletes all volumes!).
    ❌
    n8n or OpenClaw cannot see the Ollama models
    Check with docker 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 contains localhost / /v1.
    ❌
    localhost:5678 does not open from Windows
    First look at docker compose ps — is the container running? Then curl -sf http://localhost:5678/healthz in Ubuntu. If it works there but not in the browser, restart WSL: in PowerShell wsl --shutdown, then start Docker Desktop. Manual port forwarding is not needed.
    ❌
    WSL2 keeps rebooting once Ollama starts
    OpenClaw's documentation describes a known problem on WSL2 with NVIDIA: the ollama.service unit with Restart=always loads a model at startup and Windows kills the virtual machine in a loop. Fix: sudo systemctl disable ollama and start Ollama by hand, or in %USERPROFILE%\.wslconfig add the line autoMemoryReclaim=disabled under [experimental], then wsl --shutdown.
    🔐
    Do not open the stack to the internet "just like that"
    Everything here is bound to 127.0.0.1 on 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

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

  1. n8n: install using Docker Compose — Compose v2, the WSL note, Postgres.
  2. n8n: install with Docker — timezone, stable and beta versions.
  3. n8n-hosting: Compose with Postgres — the docker.n8n.io/n8nio/n8n image, Postgres 18 PGDATA.
  4. n8n: environment variables — N8N_ENCRYPTION_KEY, N8N_HOST; also: backup and restore and task runners.
  5. Docker Desktop for Windows — requirements, licence; WSL 2 backend; release notes.
  6. Qdrant: quickstart and requirements — ports, named volumes on Windows.
  7. OpenClaw: getting started · Docker install · Ollama provider · security.
  8. nomic-embed-text on Ollama 🔒 local — the embedding model.