Self-Hosting AI Agents with Ollama and Docker

A practical, end-to-end guide for engineering teams who want a private, sovereign AI coding environment — no data leaves your network.

Why self-host?

Cloud AI providers see every keystroke, snippet, and prompt. For regulated industries (finance, healthcare, defense, government) or any team handling proprietary code, that's a non-starter. Self-hosting with Ollama + Docker gives you GPT-class coding assistance with zero outbound calls.

Prerequisites

Step 1 — Install Ollama

# One-line install on Linux/macOS
curl -fsSL https://ollama.com/install.sh | sh

# Verify
ollama --version

Step 2 — Pull a coding model

# Strong general coder, ~4.7 GB
ollama pull qwen2.5-coder:7b

# Or a smaller/faster option
ollama pull deepseek-coder-v2:16b

# Run a quick sanity check
ollama run qwen2.5-coder:7b "Write a Python function to reverse a linked list"

Step 3 — Run Ollama in Docker

Create a docker-compose.yml:

services:
  ollama:
    image: ollama/ollama:latest
    ports:
      - "11434:11434"
    volumes:
      - ollama-data:/root/.ollama
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]
    restart: unless-stopped

volumes:
  ollama-data:
docker compose up -d
docker exec -it $(docker ps -qf name=ollama) ollama pull qwen2.5-coder:7b

Step 4 — Point MANOVIK at your local Ollama

In MANOVIK's settings, choose Sovereign Mode and set the model endpoint:

MANOVIK_MODEL_PROVIDER=ollama
MANOVIK_MODEL_ENDPOINT=http://localhost:11434
MANOVIK_MODEL_NAME=qwen2.5-coder:7b

Restart MANOVIK. Every prompt now routes to your local Ollama process — nothing leaves your machine.

Step 5 — Verify it's fully offline

# Block outbound while testing
sudo iptables -A OUTPUT -p tcp --dport 443 -j REJECT
# Use MANOVIK normally; if it still works, you're sovereign.
sudo iptables -D OUTPUT -p tcp --dport 443 -j REJECT

Production tips

Next steps

You now have a fully sovereign AI coding agent. Pair it with MANOVIK's per-language memory and self-update scheduler for an offline assistant that gets smarter without ever phoning home. See how this compares to Cursor AI →