Docker AI Ollama Self-Hosted Open WebUI
5 min read

Ollama WebUI Stack: Local AI Chat

Note: Running large language models (LLMs) locally can use significant CPU and memory resources. Monitor your system temperature and resource usage. For most users, running smaller models or using a dedicated server/cloud is recommended for heavy workloads.

A local AI chat application that runs entirely on your machine using Docker Compose. This project uses Open WebUI, a beautiful and feature-rich interface for Ollama, combined with local AI model deployment.

πŸ“‹ Table of Contents

πŸš€ Features

  • Modern Web UI: Real-time chat, Markdown, code highlighting, and theme support
  • Model Management: Easy model switching, settings management, and updates
  • Rich Chat: Persistent history, system prompts, custom templates, and conversation branching
  • Data Handling: Docker volumes for persistence
  • Security: Local-only deployment with optional authentication

πŸ—οΈ Architecture

System Components

  1. Open WebUI: A modern web interface built with React and FastAPI. Runs on port 8080 (mapped to 3000). Depends on Ollama API for model interactions.
  2. Ollama API: The Docker-containerized model hosting service that manages AI model lifecycle. Runs on port 11434. Handles model loading, inference, and management.
  3. Docker Volumes:
    • ollama_data: Stores model files and Ollama configurations
    • open_webui_data: Persists chat history and user settings

System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                              Host Machine                               β”‚
β”‚                                                                         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚   Open WebUI      β”‚    β”‚    Ollama API     β”‚    β”‚  Docker Engine  β”‚  β”‚
β”‚  β”‚   Container       β”‚    β”‚    Container      β”‚    β”‚                 β”‚  β”‚
β”‚  β”‚                   β”‚    β”‚                   β”‚    β”‚                 β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚    β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚    β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
β”‚  β”‚  β”‚  Frontend β”‚    β”‚    β”‚  β”‚  API      β”‚    β”‚    β”‚  β”‚ Volumes   β”‚  β”‚  β”‚
β”‚  β”‚  β”‚  (React)  β”‚    β”‚    β”‚  β”‚  Server   β”‚    β”‚    β”‚  β”‚           β”‚  β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚    β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚    β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”  β”‚  β”‚  β”‚
β”‚  β”‚        β”‚          β”‚    β”‚        β”‚          β”‚    β”‚  β”‚  β”‚ollamaβ”‚  β”‚  β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚    β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚    β”‚  β”‚  β”‚data β”‚  β”‚  β”‚  β”‚
β”‚  β”‚  β”‚  Backend  β”‚    β”‚    β”‚  β”‚  Model    β”‚    β”‚    β”‚  β”‚  β””β”€β”€β”€β”€β”€β”˜  β”‚  β”‚  β”‚
β”‚  β”‚  β”‚  (FastAPI)β”‚    β”‚    β”‚  β”‚  Manager  β”‚    β”‚    β”‚  β”‚           β”‚  β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚    β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚    β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”  β”‚  β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚  β”‚  β”‚webuiβ”‚  β”‚  β”‚  β”‚
β”‚            β”‚                        β”‚              β”‚  β”‚  β”‚data β”‚  β”‚  β”‚  β”‚
β”‚            β”‚                        β”‚              β”‚  β”‚  β””β”€β”€β”€β”€β”€β”˜  β”‚  β”‚  β”‚
β”‚            β”‚                        β”‚              β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
β”‚            β”‚                        β”‚              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚            β”‚                        β”‚                                   β”‚
β”‚            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Data Flow

  1. User Request Flow:

    • User input β†’ Open WebUI Frontend (React)
    • Frontend β†’ Open WebUI Backend (FastAPI)
    • Backend β†’ Ollama API
    • Ollama API β†’ Model Manager β†’ LLM Model
  2. Response Flow:

    • LLM Model β†’ Model Manager β†’ Ollama API
    • Ollama API β†’ Open WebUI Backend
    • Backend β†’ Frontend β†’ User

Container Configuration

  • Open WebUI:

    • Port: 3000 (host) β†’ 8080 (container)
    • Environment:
      • OLLAMA_API_BASE_URL=http://ollama:11434/api
      • WEBUI_SECRET_KEY (for authentication)
    • Volume: open_webui_data:/app/backend/data
  • Ollama:

    • Port: 11434 (host) β†’ 11434 (container)
    • Volume: ollama_data:/root/.ollama
    • Command: serve

Volume Management

Ollama Data Volume

  • Location: Managed by Docker
  • Contents: Model files, configurations, and cache data
  • Mount Point: /root/.ollama in the Ollama container
  • Purpose: Persists downloaded models and their configurations

WebUI Data Volume

  • Location: Managed by Docker
  • Contents: Chat history, user settings, system prompts, and custom configurations
  • Mount Point: /app/backend/data in the Open WebUI container
  • Purpose: Maintains user data and preferences across container restarts

πŸ“‹ Prerequisites

  • Software: Docker (20.10.0+), Docker Compose (2.0.0+), Git
  • Hardware:
    • CPU: 2+ cores (4+ recommended)
    • RAM: 8GB (16GB+ recommended)
    • Storage: 10GB+ free space (SSD recommended)
    • GPU: NVIDIA GPU with CUDA support (recommended)
  • OS: Linux, macOS, or Windows with WSL2

πŸš€ Quick Start

  1. Clone Repository
git clone https://github.com/toasobi-lab/ollama-webui-stack.git
cd ollama-webui-stack
  1. Start Services
docker compose up -d
docker compose ps  # Check status
  1. Access Web Interface

βš™οΈ Configuration

Ports

  • WebUI: 3000 (host) β†’ 8080 (container)
  • Ollama API: 11434 (host) β†’ 11434 (container)

Resource Limits

services:
  ollama:
    deploy:
      resources:
        limits:
          cpus: '2'
          memory: 4G
  webui:
    deploy:
      resources:
        limits:
          cpus: '1'
          memory: 2G

πŸ” Troubleshooting

Common Issues

  1. Port Conflicts: Check ports 3000 and 11434, modify mappings in docker-compose.yml
  2. Volume Issues: Check permissions and disk space
  3. Container Issues: Check logs (docker compose logs), restart/rebuild containers
  4. Performance: Monitor resources, verify model size matches hardware

Help Resources

🀝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add some amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

Docker AI Ollama Self-Hosted Open WebUI