惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

阮一峰的网络日志
阮一峰的网络日志
J
Java Code Geeks
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
V
Visual Studio Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
M
MIT News - Artificial intelligence
U
Unit 42
博客园 - 三生石上(FineUI控件)
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
I
InfoQ
WordPress大学
WordPress大学
H
Help Net Security
D
Docker
B
Blog
腾讯CDC
A
About on SuperTechFans
Recent Announcements
Recent Announcements
雷峰网
雷峰网
有赞技术团队
有赞技术团队
C
Check Point Blog
Y
Y Combinator Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Open-WebUI + Ollama Guide: Run LLMs Locally with Docker
Loki Bein Bl · 2026-05-09 · via DEV Community

1️⃣ Introduction

Welcome to the ultimate Open-WebUI guide. If you've ever wanted the power and sleek interface of ChatGPT but with the privacy of a local server, you are in the right place.

Ollama is a lightweight inference engine that makes running large language models (LLMs) dead simple, while Open-WebUI (formerly Ollama WebUI) provides a beautiful, feature-rich, and extensible front-end. By combining them, you can build your own private AI assistant.
Why a self-hosted FOSS version matters:
Absolute Privacy: Your chats, code snippets, and intellectual property never leave your machine.
Zero Subscription Costs: Run powerful open-source models for free.
Offline Access: Work seamlessly even without an internet connection.
TL;DR - What you will accomplish today:
Install Docker & Docker Compose.
Deploy a unified Ollama and Open-WebUI stack using a single file.
Prevent data loss with persistent volumes.
Download and run Llama locally.

2️⃣ Prerequisites

Before we spin up our Ollama local LLM stack, ensure your system meets these baseline requirements:
Hardware: * RAM: 8 GB minimum (16 GB highly recommended to run 7B-8B parameter models).
CPU: Modern multi-core processor.
GPU (Optional but recommended): An NVIDIA GPU with at least 6GB VRAM will drastically improve token generation speed.
Software: Docker and Docker-Compose installed on your system. (If you haven't done this yet, check out our Beginner's Guide to Docker).
Network: Ports 8080 (WebUI) and 11434 (Ollama API) available.

3️⃣ Quick-Start Installation

The biggest mistake beginners make is running Open-WebUI and Ollama in separate, disjointed Docker commands, leading to localhost connection errors. We will solve this by deploying them together in a single docker-compose.yml file.

Create a new directory and create your compose file:

mkdir open-webui-stack && cd open-webui-stack
nano docker-compose.yml

Paste the following configuration:

version: '3.8'

services:
ollama:
image: ollama/ollama:latest
container_name: ollama
volumes:
- ollama_data:/root/.ollama
ports:
- "11434:11434"
restart: unless-stopped
# Uncomment the following lines if you have an NVIDIA GPU and nvidia-docker2 installed
# deploy:
# resources:
# reservations:
# devices:
# - driver: nvidia
# count: 1
# capabilities: [gpu]

open-webui:
image: ghcr.io/open-webui/open-webui:main
container_name: open-webui
volumes:
- open-webui_data:/app/backend/data
ports:
- "8080:8080"
environment:
- OLLAMA_BASE_URL=http://ollama:11434
- WEBUI_AUTH=True
depends_on:
- ollama
restart: unless-stopped

volumes:
ollama_data:
open-webui_data:

Save the file and run:
docker compose up -d

First-run verification: Wait about 60 seconds for the containers to initialize, then open your browser and navigate to http://localhost:8080. You should be greeted by the Open-WebUI login screen!

4️⃣ Detailed Configuration

Let's break down why this configuration solves the most common self-hosting headaches:
Persistent Storage (Volumes): Notice the ollama_data and open-webui_data volumes? Without these, every time you update or restart your container, you would lose your downloaded models and chat history. This setup ensures your data is permanently safe.
Internal Network Routing: By setting OLLAMA_BASE_URL=http://ollama:11434, we tell the WebUI to talk directly to the Ollama container via Docker's internal DNS. This completely bypasses annoying localhost or 127.0.0.1 routing conflicts.
Authentication (WEBUI_AUTH=True): This forces users to create an account before accessing the AI, securing your server from unauthorized use.

Pro-Tip: If you want to access this outside your home network, we highly recommend putting Open-WebUI behind Nginx Proxy Manager or Traefik with an SSL certificate.

5️⃣ Common Use-Cases & Mini-Projects

Downloading Your First Model
Once logged into Open-WebUI, click on the Settings gear, navigate to Models, and type llama3 or llama3.1 into the pull model field. Click download.
Alternatively, you can pull a model directly via your terminal:
docker exec -it ollama ollama run llama3.1

API Access for Developers
Because we exposed port 11434, you can use your new local LLM server just like the OpenAI API. Test it with this simple curl request:
curl -X POST http://localhost:11434/api/generate -d '{
"model": "llama3.1",
"prompt": "Why is the sky blue? Explain in one sentence.",
"stream": false
}'

6️⃣ Troubleshooting & FAQ

Q: My GPU isn't being detected by Ollama. Tokens are generating very slowly!

A: If you are on Linux with an NVIDIA card, you must install the NVIDIA Container Toolkit (nvidia-docker2). Once installed, uncomment the deploy block in the docker-compose.yml file and restart the stack (docker compose up -d --force-recreate).

Q: I keep getting "Out of Memory" errors on my 8GB RAM machine.

A: Standard 7B or 8B models might be too heavy for your system. Switch to a smaller, highly efficient model. Try pulling gemma:2b or Microsoft's phi3 inside the Open-WebUI interface.

Q: Open-WebUI says "Ollama connection failed."

A: Double-check that your OLLAMA_BASE_URL is set to http://ollama:11434 (not localhost) and that the ollama container is running without restart loops (docker ps).

7️⃣ Security & Production Hardening

If you plan to expose this setup to the internet, you must harden it:
Disable Open Signups: Once you have created your admin account, go to the WebUI Admin Panel -> Settings -> General, and turn off "Enable New User Signups".
Backup Strategy: Regularly back up your Docker volumes. You can easily tarball your volumes located in /var/lib/docker/volumes/ to keep your chat history safe.
Reverse Proxy: Never expose port 8080 directly to the web. Route it through a proxy manager with Let's Encrypt SSL.

8️⃣ Extending the Stack

Your private AI assistant doesn't have to exist in a vacuum. You can seamlessly integrate this setup with other FOSS homelab tools:
Give it internet access: Connect Open-WebUI to SearXNG (Self-Hosted Search Engine) to allow your LLM to scrape the live web.
Safe Code Execution: Integrate Open-Terminal to give your AI agents a sandboxed browser-based shell to write and test code safely.

9️⃣ Conclusion & Next Steps

You now have a fully functional, highly secure, and persistent Ollama local LLM server with a gorgeous user interface. You've eliminated third-party privacy risks and unlocked the world of open-weight AI models.