Ubuntu 24.04 本地部署 Open WebUI 与 Ollama
Open WebUI 提供了友好的界面来管理本地大模型,结合 Ollama 可实现私有化部署。以下基于 Ubuntu 24.04 环境,通过 Docker Compose 进行封装运行。
前置准备
参考官方文档:Open WebUI 文档
部署步骤
1. 拉取项目
使用 Git 克隆官方仓库(建议使用稳定源):
git clone https://github.com/open-webui/open-webui.git
cd open-webui
2. 配置环境变量
由于本地已运行 Ollama 服务,需修改 docker-compose.yaml 及 .env 文件中的连接地址。
复制示例配置:
cp .env.example .env
编辑 .env 文件,设置 Ollama 后端连接地址。宿主机地址通常使用 host.docker.internal:
# .env
OLLAMA_BASE_URL='http://host.docker.internal:11434'
CORS_ALLOW_ORIGIN='*'
FORWARDED_ALLOW_IPS='*'
DO_NOT_TRACK=true
ANONYMIZED_TELEMETRY=false
3. 修改 Docker Compose 配置
在 docker-compose.yml 中,确保删除了内置的 Ollama 服务依赖,并正确映射端口与环境变量。
services:
open-webui:
build:
context: .
dockerfile: Dockerfile
image: ghcr.io/open-webui/open-webui:${WEBUI_DOCKER_TAG-main}
container_name: open-webui
volumes:
- open-webui:/app/backend/data
ports:
- "${OPEN_WEBUI_PORT-3000}:8080"


