Local AI Stack with Docker: Ollama, Open WebUI & Qdrant

Why one file beats three separate installs

Running a language model locally is easy the first time; keeping it working is harder. Install Ollama one weekend, add a chat interface the next, then a vector database for retrieval-augmented generation (RAG) later, and you have three services, three startup commands, and no record of how they fit together. A Docker Compose file fixes that: it describes the whole stack in one place, so rebuilding it is a single command.

This guide builds a private stack: Ollama runs the models, Open WebUI provides a ChatGPT-style chat interface, and Qdrant stores vector embeddings for search over your documents. Everything runs on your machine, and each service keeps its data in a named Docker volume, so a restart does not wipe your models, chats, or vectors.

New to Ollama? Start with our guide on running an open model locally with Ollama. If you only want the chat interface, our Open WebUI tutorial covers that piece alone.


Source: TechOtakuLab — a VPS running Ollama in Docker with an Open WebUI front end.

What each service does

  • Ollama downloads and serves open models on port 11434. It is the engine; the other services talk to it, not to the cloud.
  • Open WebUI is the browser interface on port 3000. It adds accounts, chat history, and document upload, and points at Ollama through the internal Docker network.
  • Qdrant is a vector database on ports 6333 (HTTP) and 6334 (gRPC). It stores embeddings — numerical representations of text — so your own code can search documents by meaning, not just keywords.

One boundary matters: adding Qdrant to the same file does not make it Open WebUI's backend. Open WebUI has its own document handling; Qdrant is the separate store you use when building a RAG app. Our local RAG guide with Ollama and Qdrant shows that step. The value here is that both pieces are already running, on known ports, when you get there.

Prerequisites

  • Docker Engine or Docker Desktop, with Compose v2 — check with docker --version and docker compose version.
  • At least 16 GB of RAM for comfortable use with an 8B model, plus disk space for models: an 8B model at 4-bit quantization is roughly 5 GB.
  • On Linux with an NVIDIA GPU, the NVIDIA Container Toolkit for GPU acceleration. On a Mac, skip GPU passthrough: Docker cannot hand the Apple GPU to a container, so Ollama in Docker runs on CPU. The Mac alternative is in the troubleshooting section.

Step 1: Write the Compose file

Create a folder and save the following as docker-compose.yml. Every port is bound to 127.0.0.1, so services are reachable from your machine only — Ollama has no login, so never expose 11434 to a network. Replace the secret placeholder with a long random string (openssl rand -hex 32), and never commit a real key publicly.

services:
  ollama:
    image: ollama/ollama:latest
    container_name: ollama
    restart: unless-stopped
    environment:
      - OLLAMA_HOST=0.0.0.0
      - OLLAMA_KEEP_ALIVE=30m
    ports:
      - "127.0.0.1:11434:11434"
    volumes:
      - ollama_data:/root/.ollama

  open-webui:
    image: ghcr.io/open-webui/open-webui:main
    container_name: open-webui
    restart: unless-stopped
    depends_on:
      - ollama
    environment:
      - OLLAMA_BASE_URL=http://ollama:11434
      - WEBUI_SECRET_KEY=replace-this-with-a-long-random-string
    ports:
      - "127.0.0.1:3000:8080"
    volumes:
      - open-webui-data:/app/backend/data

  qdrant:
    image: qdrant/qdrant:latest
    container_name: qdrant
    restart: unless-stopped
    ports:
      - "127.0.0.1:6333:6333"
      - "127.0.0.1:6334:6334"
    volumes:
      - qdrant_storage:/qdrant/storage

volumes:
  ollama_data:
  open-webui-data:
  qdrant_storage:

Three details matter. OLLAMA_HOST=0.0.0.0 lets Ollama accept connections from other containers; without it, Open WebUI may not reach it. Open WebUI talks to http://ollama:11434, using the service name as hostname — Docker's internal DNS — so localhost would be wrong inside the container. And the named volumes hold the data: models, chats and accounts, and vectors respectively.

Step 2: Start the stack and pull a model

From the project folder, run:

docker compose up -d
docker compose ps

The first run downloads three images, so allow a few minutes. Then pull a chat model and an embedding model:

docker exec ollama ollama pull llama3.1:8b
docker exec ollama ollama pull nomic-embed-text
docker exec ollama ollama list

The models land in the ollama_data volume, so they survive a restart, and the step is repeatable in a script.

Step 3: Verify each service

Check the endpoints before opening the chat interface:

curl http://localhost:11434/api/tags
curl http://localhost:6333/

Then prove the model loads with a real chat request:

curl http://localhost:11434/api/chat -d '{
  "model": "llama3.1:8b",
  "messages": [{"role": "user", "content": "Say hello in one sentence."}],
  "stream": false
}'

Now open http://localhost:3000. The first account you create becomes the administrator, so use a strong password. If the model list appears, the wiring worked. Qdrant's dashboard is at http://localhost:6333/dashboard; an empty dashboard now is normal, because no collection exists yet.

Step 4: Optional NVIDIA GPU acceleration

The base file runs on CPU. With an NVIDIA GPU on Linux and the Container Toolkit installed, add a deploy block to the Ollama service only — Open WebUI and Qdrant do not need the GPU:

    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]

Then run docker compose up -d again. Keep this block out of the base file if the machine may lack an NVIDIA GPU: without the toolkit, Compose refuses to start instead of falling back to CPU. Verify with nvidia-smi while a model is loaded.

Daily use, updates, and backups

Daily use is simple: open http://localhost:3000 and chat. For a new model, run docker exec ollama ollama pull <model>. To update, pull new images and recreate the containers — the volumes keep your data:

docker compose pull
docker compose up -d
docker compose ps

To stop without losing anything, run docker compose down. Do not add -v unless you mean it: it deletes the volumes, taking every model, chat, and collection with them. A Compose file alone is not a backup — back up the volumes themselves.

Troubleshooting

  • Open WebUI shows no models. Check that Ollama is running, that OLLAMA_BASE_URL is http://ollama:11434 (the service name, not localhost), and that OLLAMA_HOST=0.0.0.0 is set.
  • Port already in use. Another service may own 11434, 3000, or 6333. Stop it, or change the host-side port — for example, "127.0.0.1:3001:8080" — and restart.
  • GPU block fails to start. Remove the deploy block, confirm the stack runs on CPU, then install the NVIDIA Container Toolkit and re-add it.
  • Slow answers on a Mac. This is expected: the container cannot use the Apple GPU. For faster Mac performance, run Ollama natively from the desktop app and point Open WebUI's container at http://host.docker.internal:11434.
  • Qdrant dashboard is empty. That is normal before you create a collection. Create one from your RAG script or the dashboard before blaming the search code.

What to build next

Once the stack is up, point a small script at Qdrant, embed a folder of documents with nomic-embed-text, and search them before asking llama3.1:8b a question. That RAG loop turns a chat demo into a tool answering from your own material.

Comments

Popular posts from this blog

Open-Source AI Weekly: Bonsai, GigaChat 4 Lead

Claude Claims Proof of Riemann Hypothesis After 167 Years

How to Build an AI Agent with LangGraph in 30 Minutes