Here's a step-by-step solution to add models to OpenWebUI + Ollama in Docker, with systematic implementation details:
Phase 1: Environment Validation
-
Verify Docker Setup
docker ps | grep -E 'openwebui|ollama'
Ensure both containers are running and in the same Docker network.
-
Check Ollama Accessibility
docker exec -it ollama ollama list
Confirm Ollama is operational and shows existing models.
Phase 2: Model Integration
Option A: Pull Existing Models via Ollama CLI
-
Access Ollama Container
docker exec -it ollama bash
-
Pull Target Model (e.g., Llama 3.1)
ollama pull llama3.1
Option B: Add Custom Models
-
Prepare Model Files
Mount model directory in docker-compose.yml:
services:
ollama:
volumes:
- ./models:/root/.ollama/models
-
Create Model Definition (Modelfile)
# Inside Ollama container
nano Modelfile
Example for a GGUF model:
FROM /root/.ollama/models/mymodel.gguf
TEMPLATE "{{.Prompt}}"
-
Build & Deploy
ollama create mymodel -f Modelfile
ollama pull mymodel
Phase 3: OpenWebUI Configuration
-
Update OpenWebUI Environment
In docker-compose.yml:
services:
openwebui:
environment:
- OLLAMA_BASE_URL=http://ollama:11434
depends_on:
- ollama
-
Restart Services
docker-compose down && docker-compose up -d
Phase 4: Verification
-
Check Model Availability
Access OpenWebUI → Settings → Models.
Your model should appear in the dropdown.
-
Test Inference
Send a prompt to verify model responsiveness.
Troubleshooting Checklist
-
Connection Issues
- Confirm
OLLAMA_BASE_URL matches Ollama's container name and port.
- Check Docker network:
docker network inspect bridge.
-
Model Visibility
- Ensure model name in OpenWebUI matches Ollama's
ollama list output.
- Clear OpenWebUI cache:
docker exec -it openwebui bash -c "rm -rf /app/backend/data/cache/*".
-
Permission Errors
- For mounted models, set proper permissions:
chmod -R 755 ./models
Advanced: Multi-Model Routing (Optional)
For complex workflows, deploy a model router like OpenRouter in front of Ollama using Docker:
services:
openrouter:
image: openrouter/openrouter
environment:
- OLLAMA_URL=http://ollama:11434
ports:
- "8000:8000"
Configure OpenWebUI to connect to http://openrouter:8000.
This implementation follows systems engineering principles with:
- Modular Architecture: Clear service boundaries between OpenWebUI and Ollama
- Fault Isolation: Containerized components with health checks
- Scalability: Volume mounts for model storage expansion
- Reproducibility: Version-locked Docker images
Let me know if you need help with specific model architectures or advanced deployment scenarios.