Applied AI Updated Nov 21, 2026 Ubuntu 24.04 LTS (Kernel 6.8, CUDA 12.4)

Open WebUI with Docker Compose and NVIDIA GPU on Linux

Deploy Open WebUI alongside Ollama using Docker Compose and the NVIDIA Container Toolkit on Ubuntu 24.04 with persistent storage, GPU passthrough, and reverse proxy hardening.
Z
Zaisha
Staff Writer · Verified Editor
Published Oct 25, 2026 · Updated Nov 21, 2026 · 5 min read · 894 words
Quick Overview

This deep-dive covers open webui docker compose nvidia with actionable analysis, practical implications, and expert insights.

Open WebUI with Docker Compose and NVIDIA GPU on Linux

Why Pair Open WebUI with Docker Compose and NVIDIA GPU Passthrough?

Running local large language models through a terminal works well for quick tests, but daily engineering workflows benefit from a full browser workspace with chat history, document retrieval (RAG), prompt templates, and multi-model switching. Open WebUI provides that interface while Ollama handles model downloads and CUDA inference. Packaging both services in Docker Compose gives you reproducible upgrades, isolated networking, and predictable GPU resource allocation on Ubuntu 24.04 LTS.

Prerequisites and Driver Verification

Before configuring containers, verify that your Linux host has a working proprietary NVIDIA driver and Docker Engine with the Compose v2 plugin. Avoid Snap-packaged Docker builds because they frequently conflict with NVIDIA runtime hooks.

nvidia-smi
docker --version
docker compose version

If nvidia-smi fails, install the recommended NVIDIA driver for your card from the Ubuntu repository and reboot before proceeding:

sudo apt update
sudo ubuntu-drivers install
sudo reboot

Step 1: Install the NVIDIA Container Toolkit

Standard Docker containers cannot access host CUDA devices directly. The NVIDIA Container Toolkit bridges the host driver into the container runtime without bundling duplicate driver binaries inside each image.

curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey \
  | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg

curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list \
  | sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' \
  | sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list

sudo apt update
sudo apt install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker

Run a quick smoke test container to confirm Docker can enumerate your GPU:

docker run --rm --gpus all nvidia/cuda:12.4.1-base-ubuntu22.04 nvidia-smi

You should see the same GPU model, driver version, and VRAM capacity reported on the host.

Step 2: Create the Production Docker Compose Stack

Create a dedicated directory for the stack so environment variables and Compose definitions stay version-controlled and easy to back up.

mkdir -p ~/stacks/open-webui && cd ~/stacks/open-webui

Create docker-compose.yml with private internal networking, explicit GPU reservation for Ollama, and localhost-only port binding for Open WebUI:

services:
  ollama:
    image: ollama/ollama:latest
    container_name: ollama
    restart: unless-stopped
    volumes:
 - ollama_data:/root/.ollama
    environment:
 - OLLAMA_KEEP_ALIVE=10m
 - OLLAMA_NUM_PARALLEL=2
 - OLLAMA_MAX_LOADED_MODELS=2
    deploy:
      resources:
        reservations:
          devices:
 - driver: nvidia
              count: all
              capabilities: [gpu]
    networks:
 - ai_internal

  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}
 - ENABLE_SIGNUP=true
 - DEFAULT_MODELS=llama3.1:8b
    volumes:
 - open_webui_data:/app/backend/data
    networks:
 - ai_internal

volumes:
  ollama_data:
  open_webui_data:

networks:
  ai_internal:
    driver: bridge

Generate a strong random secret key in a local .env file so session cookies remain valid across restarts:

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

Step 3: Launch the Stack and Pull Your First Model

Start both containers in detached mode and verify they reach a healthy running state:

docker compose up -d
docker compose ps
docker compose logs -f --tail=50

Pull an instruction-tuned model directly inside the Ollama container and confirm it loads onto the GPU:

docker exec -it ollama ollama pull llama3.1:8b
docker exec -it ollama ollama ps

The ollama ps output should display 100% GPU in the processor column. If it shows CPU offload, check whether your model exceeds available VRAM or whether nvidia-ctk was applied to Docker.

Step 4: Security Hardening and Reverse Proxy Access

Binding Open WebUI to 127.0.0.1:3000 prevents accidental exposure on public cloud or LAN interfaces. After opening http://127.0.0.1:3000 and registering the first administrator account, immediately lock down public signups by editing docker-compose.yml to set ENABLE_SIGNUP=false and recreating the container:

docker compose up -d open-webui

When exposing the interface to your private LAN or team domain, place Nginx or Caddy in front with TLS 1.3 and WebSocket forwarding enabled so token streaming works without buffering delays. For Caddy, a minimal site block takes four lines:

ai.internal.example.com {
    reverse_proxy 127.0.0.1:3000
}

Step 5: Routine Maintenance and Volume Backups

Keep both images up to date without disrupting your saved chats or downloaded weights:

docker compose pull
docker compose up -d
docker image prune -f

To back up your Open WebUI SQLite database, prompts, and RAG documents, archive the named volume while the container is paused for a few seconds:

docker compose stop open-webui
docker run --rm -v open-webui_open_webui_data:/data -v "$(pwd)":/backup alpine \
  tar czf /backup/open-webui-backup-$(date +%F).tar.gz -C /data .
docker compose start open-webui

Troubleshooting Common GPU and Streaming Issues

SymptomLikely CauseFix
could not select device driver nvidiaDocker daemon not configured for NVIDIA runtimeRun sudo nvidia-ctk runtime configure --runtime=docker and restart Docker
Models list is empty in Open WebUIWrong OLLAMA_BASE_URL or separate networksUse http://ollama:11434 on the same Compose bridge network
Tokens arrive in bursts instead of smoothlyReverse proxy response buffering enabledSet proxy_buffering off; in Nginx or use Caddy
CUDA out-of-memory error under loadToo many concurrent contexts loadedLower OLLAMA_NUM_PARALLEL to 1 or use a Q4_K_M quantized model

Summary

With Docker Compose and the NVIDIA Container Toolkit properly wired, Open WebUI and Ollama form a clean, private AI workspace on Linux. You gain full GPU acceleration, isolated internal networking, simple rollbacks, and predictable backups without cluttering your host Python environment.

Tested & Verified Environment
Author Verified
Operating System: Ubuntu 24.04 LTS (Kernel 6.8, CUDA 12.4)
Verification Date: Nov 21, 2026
Testing Methodology & Notes: Verified on Ubuntu 24.04 LTS with Docker Engine 27.1, NVIDIA Driver 550, and RTX 4070 12GB VRAM. Container GPU passthrough verified via nvidia-smi inside the Ollama container.

Was this technical analysis helpful?

Your feedback informs our benchmark updates and ongoing article audits.

✓ Thank you for your feedback! Our editorial engineers review submissions weekly.

Frequently Asked Questions

Structured for search engines and AI answer systems (AEO/GEO).

Most connection errors happen when OLLAMA_BASE_URL points to localhost instead of the Docker Compose service name (http://ollama:11434). Placing both services on the same Compose network resolves DNS automatically.

Open WebUI itself uses minimal RAM (around 300 to 500 MB) and no VRAM unless you enable local Whisper or embedding models. VRAM depends on the Ollama model: 8B Q4 models fit comfortably in 8 GB VRAM, while 14B to 32B models benefit from 12 to 24 GB VRAM.

Because user accounts, chats, and RAG embeddings live in the open-webui named volume, running docker compose pull followed by docker compose up -d upgrades the image cleanly with zero data loss.

Yes. Set ENABLE_SIGNUP=false in your Compose environment or disable new registrations from Admin Panel > Settings > General right after registering the first administrator user.

More answers in our FAQ hub.

Z
Zaisha

Tech journalist covering AI, software, and emerging technology with a focus on practical insights.

Testing Standards: Tutorials and guides are hands-on tested on Ubuntu Linux workstations before release.
View all articles by Zaisha

Practical Linux & Applied AI Newsletter

Get new tested tutorials and benchmark comparisons delivered directly to your inbox. Zero spam.

Join Weekly guides readers getting our weekly digest.

  • Practical Linux administration & terminal workflows
  • Tested open-source AI setups & benchmarks
  • Zero spam - unsubscribe anytime

Join Weekly guides readers · Weekly digest · Unsubscribe anytime. RSS

Continue Exploring