Blog / Tutorials / How to self-host Open WebUI with Ollama using Docker Compose
(last updated: )

How to self-host Open WebUI with Ollama using Docker Compose

Run a private ChatGPT-style chat app on your own VPS. This guide sets up Open WebUI and Ollama with Docker Compose, sizes CPU and GPU servers, adds HTTPS with Caddy, and covers backups and updates.

12 min read
Blog header: an Open WebUI tile and an Ollama tile linked by glowing lines to a padlocked chat bubble standing on a server platform.

In short. Open WebUI is a browser chat interface and Ollama is the runtime that serves the models. Docker Compose runs both on one VPS in about 15 minutes. A CPU-only VPS with 8-16 GB RAM handles 3B to 8B models, while 20B models and larger need a GPU. Bind both containers to 127.0.0.1, put Caddy in front for HTTPS, and back up the open-webui volume.


An Open WebUI Docker setup with Ollama gives you a private, ChatGPT-style chat app on a server you control. Your prompts and files stay on your VPS, and you choose the models. This is a short route to self-hosted LLM chat for a small team: one Compose file, two containers, and a domain name.

What is Open WebUI and why pair it with Ollama?

Open WebUI is a self-hosted web interface for chatting with large language models, and Ollama is the server that downloads and runs those models. They do different jobs and run as a pair. Open WebUI handles users, chat history, document uploads, and model switching. Ollama handles model files, memory, and token generation, and exposes an API on port 11434.

The project started life as Ollama WebUI and was later renamed, which is why you still see both names in search results. An Ollama Open WebUI stack is the default combination: Open WebUI detects Ollama models automatically once OLLAMA_BASE_URL points at the Ollama API.

Open WebUI also talks to any OpenAI-compatible backend. Move a model to vLLM later and you keep the same interface. The LLM inference guide covers vLLM setup, and what Ollama is and how to use it with n8n has more Ollama background. Either backend keeps this a self-hosted AI stack, so nothing leaves your server unless you add an external API.

Open WebUI requirements: CPU vs GPU VPS sizing

Plan 8 GB RAM for 3B models, 12-16 GB RAM for 8B models, and a GPU with 16-24 GB+ VRAM for 20B-32B models. Open WebUI itself is light, so the model decides. A practical rule is the model file size plus a few GB for the context window, Open WebUI, and the operating system. The download sizes below come from the Ollama library and use its default 4-bit quantized tags.

Model classExample Ollama tag and download sizeMemory to plan forContabo fit
1B-4Bllama3.2:3b (2.0 GB), qwen3:4b (2.5 GB)8 GB RAMCore VPS (Cloud VPS 4)
7B-9Bqwen3:8b (5.2 GB)12-16 GB RAMPerformance VPS (Cloud VPS Plus 6)
12B-14Bgemma4:12b (about 8 GB), qwen3:14b (9.3 GB)24 GB+ RAM, or a GPU for speedPerformance VPS (Cloud VPS Plus 8) or GPU VPS
20B-32Bgpt-oss:20b (14 GB), qwen3:32b (20 GB)16-24 GB+ VRAMGPU VPS
70B-120Bgpt-oss:120b (65 GB)80 GB+ VRAMGPU VPS (96 GB VRAM)

On a CPU-only Ollama VPS, token speed depends on memory bandwidth and core count, so a 3B or 8B model is the comfortable ceiling for an interactive self-hosted LLM without a GPU. The Ollama GPU path starts paying off at 12B and becomes the only realistic option above 20B.

Install Docker and Docker Compose on your VPS

You need Docker Engine with the Compose plugin before you can run Ollama Docker containers. Follow the step-by-step guide to installing Docker on Ubuntu, then confirm both tools respond:

docker --version
docker compose version

Work as a non-root user with sudo rights and SSH key login.

How to install Ollama on Ubuntu with Docker

To install Ollama on Ubuntu with Docker, define it as a Compose service with a named volume for the models. Create a project folder and a first version of the Compose file:

mkdir -p ~/open-webui && cd ~/open-webui
nano docker-compose.yml
services:
  ollama:
    image: ollama/ollama:latest
    container_name: ollama
    restart: unless-stopped
    ports:
      - "127.0.0.1:11434:11434"
    volumes:
      - ollama:/root/.ollama

volumes:
  ollama:

Start the container, pull a first model, and check that it is listed:

docker compose up -d
docker compose exec ollama ollama pull llama3.2:3b
docker compose exec ollama ollama list
curl http://127.0.0.1:11434/api/version

The port is bound to 127.0.0.1, so the Ollama API answers only on the server itself. If you prefer Ollama as a native systemd service instead of a container, the official installer is curl -fsSL https://ollama.com/install.sh | sh. Most “install Ollama Ubuntu” tutorials stop at that script. The rest of this guide stays with Docker, which keeps your Ollama VPS easy to rebuild and update.

Open WebUI Docker Compose setup (Ollama + Open WebUI)

The complete Open WebUI Docker Compose file adds a second service for the Open WebUI install that reaches Ollama over the internal Compose network. First, generate a secret key so logins survive container rebuilds:

echo "WEBUI_SECRET_KEY=$(openssl rand -hex 32)" > .env

Then replace docker-compose.yml with the full stack:

services:
  ollama:
    image: ollama/ollama:latest
    container_name: ollama
    restart: unless-stopped
    ports:
      - "127.0.0.1:11434:11434"
    volumes:
      - ollama:/root/.ollama

  open-webui:
    image: ghcr.io/open-webui/open-webui:main
    container_name: open-webui
    restart: unless-stopped
    depends_on:
      - ollama
    ports:
      - "127.0.0.1:3000:8080"
    environment:
      - OLLAMA_BASE_URL=http://ollama:11434
      - WEBUI_SECRET_KEY=${WEBUI_SECRET_KEY}
    volumes:
      - open-webui:/app/backend/data

volumes:
  ollama:
  open-webui:

Run docker compose up -d. Open WebUI listens on port 8080 inside the container and on 127.0.0.1:3000 on the host. Nothing is public yet, which is deliberate: the first account created becomes the administrator, so you create it before the world can reach the page.

From your own machine, open an SSH tunnel and complete the first run:

ssh -L 3000:127.0.0.1:3000 youruser@your-server-ip
  1. Open http://localhost:3000 in your browser and create the admin account.
  2. In the Admin Panel settings, confirm that new sign-ups are disabled. Current releases close sign-up after the first account, but check it before you go public.
  3. Pull a model from the interface: type a tag such as qwen3:8b in the model selector and accept the prompt to download it from Ollama.
  4. Select the model and send a first prompt. A reply confirms the Ollama WebUI connection works end to end.

Enable GPU acceleration for Ollama

To enable Ollama GPU acceleration, reserve the NVIDIA GPU for the Ollama Docker container in a Compose override file. The host needs the NVIDIA driver and the NVIDIA Container Toolkit. A Contabo GPU VPS ships on Ubuntu 24.04 with both already installed. On other servers, the NVIDIA Container Toolkit guide covers the setup.

Create docker-compose.override.yml next to the main file. Compose merges it automatically:

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

Recreate the stack, load a model, and confirm it runs on the GPU:

docker compose up -d
docker compose exec ollama ollama run qwen3:8b "Say hello"
docker compose exec ollama ollama ps
nvidia-smi

ollama ps should show 100% GPU in the processor column, and nvidia-smi lists the Ollama process with its VRAM use. The same GPU also runs SGLang, Wan 2.2 video generation, and Stable Diffusion.

Put Open WebUI behind HTTPS with a reverse proxy

Open WebUI should only be reachable through a reverse proxy that terminates HTTPS, since the chat front end of a self-hosted LLM holds every prompt your team sends. Never publish port 3000 or 11434 directly. Caddy is the shortest path because it requests and renews Let’s Encrypt certificates on its own and proxies WebSocket connections without extra configuration, which Open WebUI needs for streaming replies.

Point a DNS A record such as chat.example.com at your server, then add Caddy to the services block of docker-compose.yml:

  caddy:
    image: caddy:2
    container_name: caddy
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
      - "443:443/udp"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - caddy_data:/data
      - caddy_config:/config

Add caddy_data: and caddy_config: under the top-level volumes key, then create a Caddyfile in the same folder:

chat.example.com {
    reverse_proxy open-webui:8080
}

Run docker compose up -d and open https://chat.example.com. If you prefer a web UI for proxy rules, the Nginx Proxy Manager with Docker guide does the same job.

Secure, back up and update your self-hosted AI stack

A self-hosted AI stack stays safe with five habits: a closed firewall, closed registration, regular volume backups, routine updates, and pinned image versions.

  • Firewall: allow only SSH, 80, and 443 with UFW (sudo ufw allow OpenSSH, sudo ufw allow 80,443/tcp, then sudo ufw enable). Docker-published ports bypass UFW rules, which is why the Open WebUI and Ollama ports are bound to 127.0.0.1. The UFW guide and VPS security checklist go further.
  • Registration: keep sign-ups off and add users from the Admin Panel. After first launch, the Admin Panel setting overrides ENABLE_SIGNUP.
  • Backups: the open-webui_open-webui volume holds users, chats, and settings. Stop the container with docker compose stop open-webui, archive the volume with docker run --rm -v open-webui_open-webui:/data -v "$PWD":/backup alpine tar czf /backup/open-webui-$(date +%F).tar.gz -C /data . and start it again with docker compose start open-webui. Copy the archive off the server. Models in the Ollama volume can be pulled again, so the chat history is the part of a self-hosted LLM worth protecting.
  • Updates: run docker compose pull and then docker compose up -d. Your data and models stay in their volumes.
  • Pinned tags: replace main and latest with release tags (Open WebUI v0.13.3 at the time of writing) once the stack is stable.

Which models run well with Open WebUI on a VPS

Small instruction models such as Llama 3.2 3B and Qwen3 8B are the sensible starting point on CPU, and gpt-oss 20B is a strong first pick on a GPU.

Use caseOllama tagSizeWhat to expect
Fast CPU chatllama3.2:3b2.0 GBQuick replies, weak on multi-step reasoning
All-round CPU modelqwen3:8b5.2 GBBetter reasoning and code, slower on CPU
Image questionsgemma4:12babout 8 GBImage and text input, best on a GPU
Reasoning on GPUgpt-oss:20b14 GBApache 2.0 license, designed to run in about 16 GB of memory
Larger dense modelqwen3:32b20 GBNeeds 24 GB+ VRAM
Largest single-GPU optiongpt-oss:120b65 GBFits a single 80 GB GPU, so it runs fully in 96 GB of VRAM

For a self-hosted LLM shared by a team on one Ollama VPS, run one general model plus one specialist rather than five overlapping ones. Every loaded model competes for the same memory.

Troubleshooting common Open WebUI and Ollama issues

Most first-run problems have one of four causes.

  • No models in the selector: OLLAMA_BASE_URL does not reach Ollama. Inside Compose it must be http://ollama:11434, not localhost.
  • Logged out after every rebuild: WEBUI_SECRET_KEY is missing. Set it in .env and recreate the container.
  • Replies hang behind Nginx: the proxy drops WebSocket upgrades. Add the Upgrade and Connection headers.
  • ollama ps shows a CPU/GPU split: the model exceeds free VRAM. Pull a smaller tag or a lower quantization.

Why run Open WebUI on Contabo

Open WebUI on Contabo gives you a fixed monthly price for a private AI chat stack, with no per-token billing.

Core VPS is the entry tier for an Ollama VPS running 3B-class models, where RAM per euro matters most. Cloud VPS 4 has 4 vCPU and 8 GB RAM. Performance VPS runs on AMD EPYC CPUs with NVMe storage, the better fit for 8B models on CPU, where faster cores mean faster tokens. Cloud VPS Plus 6 (6 vCPU, 12 GB RAM) handles 8B models, Cloud VPS Plus 8 (8 vCPU, 24 GB RAM) leaves room for 14B.

GPU VPS is the Ollama GPU option for larger models. Each GPU VPS comes with a dedicated NVIDIA RTX PRO 6000 Blackwell Server Edition with 96 GB GDDR7 ECC VRAM, 18 vCPU, 96 GB RAM, and 900 GB NVMe. It ships with CUDA preinstalled and runs in Europe or US Central. That is enough VRAM to run gpt-oss:120b entirely on the GPU, or several mid-size models side by side. All prices exclude VAT and apply to monthly billing, and Cloud VPS 4 adds a one-time setup fee on monthly terms.

FAQ: Open WebUI and Ollama

Do I need a GPU to run Open WebUI with Ollama?

No. Open WebUI with Ollama runs on a CPU-only VPS, and models up to about 8B parameters, such as Llama 3.2 3B or Qwen3 8B, give usable chat speeds with 8-16 GB RAM. An Ollama GPU setup becomes worth it at 12B and above, and a model like gpt-oss 20B or Qwen3 32B needs a GPU with enough VRAM to answer at interactive speed.

How do I connect Open WebUI to Ollama in Docker?

Run both as services in one Docker Compose file and set OLLAMA_BASE_URL=http://ollama:11434 on the Open WebUI service. Compose puts the containers on a shared network, so Open WebUI reaches Ollama by its service name. If Ollama runs natively on the host instead of in Docker, point the variable at http://host.docker.internal:11434, add the host-gateway mapping, and set OLLAMA_HOST so Ollama listens beyond 127.0.0.1.

Is Open WebUI free and self-hosted?

Yes. Open WebUI is free to download and runs entirely on your own server, so chats and files never leave it. Since version 0.6.6, it uses the Open WebUI License, a permissive license with a branding clause: deployments with more than 50 users in 30 days must keep the Open WebUI branding unless they hold an enterprise license. Smaller self-hosted AI setups are unaffected.

How do I update Open WebUI with Docker Compose?

Change into the folder that holds your Open WebUI Docker Compose file and run docker compose pull, then docker compose up -d. Compose downloads the newer images and recreates only the changed containers. Users, chats, and settings survive because they live in the open-webui volume. Back up that volume first and read the release notes when moving between major versions.

Can I use Open WebUI with vLLM or other OpenAI-compatible APIs?

Yes. Open WebUI supports any OpenAI-compatible API alongside Ollama, including vLLM, SGLang, LiteLLM, and hosted providers. Add the endpoint URL and API key under the connection settings in the Admin Panel, and its models appear in the same selector. Many teams keep the Ollama WebUI setup for small models and route a large model to vLLM on a GPU.