Commercial cloud AI chatbots come with persistent privacy concerns, usage limits, and recurrent monthly subscriptions. While self-hosting large language models (LLMs) locally has become significantly easier thanks to runtimes like Ollama, a standalone offline model suffers from two major limitations: knowledge cutoffs and hallucinations on rapidly evolving current events.
By pairing Ollama with Open WebUI and SearXNG (a private, self-hosted metasearch engine), you can build an entirely private, web-connected AI assistant directly inside Docker. When you ask a query requiring real-time facts, Open WebUI queries your local SearXNG instance, strips tracking parameters, summarizes live search results, and injects relevant snippets directly into your model’s context window – all without sending a single byte of telemetry to third-party ad networks.
In this guide, we will configure an end-to-end production stack using Docker Compose, map GPU acceleration, configure local embeddings for document retrieval (RAG), and tune memory parameters for maximum responsiveness.
Architecture Overview: How Web-Search Augmented Local AI Works
The self-hosted web-search AI pipeline consists of three coordinated microservices operating on an isolated internal Docker bridge network:
- Ollama (Inference Engine): Serves quantized open-weights models (such as DeepSeek-R1-Distill, Llama 3.2, or Qwen 2.5) with direct GPU hardware acceleration via CUDA or ROCm.
- SearXNG (Private Metasearch Engine): Aggregates search results from engines like Google, Bing, DuckDuckGo, and Brave without user profiling or IP tracking, returning clean JSON results over a local HTTP endpoint.
- Open WebUI (Frontend & Orchestrator): Provides a ChatGPT-grade interface supporting multi-user management, custom system prompts, document parsing (RAG via vector embeddings), and autonomous web searching.
If you have already tuned your server swap space and firewall rules as described in our Ubuntu 24.04 and Docker production hardening guide, this container stack will integrate seamlessly while remaining protected behind your reverse proxy.
Prerequisites and Hardware Considerations
Before launching the stack, ensure your host environment meets the following requirements:
- Operating System: Linux (Ubuntu 22.04 / 24.04 LTS or Debian 12 recommended).
- Docker Engine: Version 24.0+ with the Docker Compose v2 plugin.
- NVIDIA GPU Acceleration: If running with an NVIDIA GPU, verify that the
nvidia-container-toolkitis configured properly on the host (as covered in our Immich GPU hardware transcoding guide). AMD users should map/dev/kfdand/dev/drifor ROCm. - System RAM: A minimum of 16 GB of system RAM for running 7B–8B quantized models comfortably. Refer to our Local DeepSeek-R1 and Llama 3 VRAM breakdown to verify exact memory budgets, or our LM Studio vs Ollama benchmark comparison if you are deciding between a desktop GUI and a containerized daemon.
Step 1: Directory Structure and SearXNG Configuration
Create a dedicated workspace directory on your server:
mkdir -p ~/local-ai-stack/searxng
cd ~/local-ai-stack
SearXNG requires a customized settings.yml configuration file to enable JSON search output, which Open WebUI relies on to parse external web results. Generate an arbitrary secret key and create the configuration file:
# Generate a 32-character secret key
openssl rand -hex 32
Create searxng/settings.yml and insert the following settings:
use_default_settings: true
general:
debug: false
instance_name: "Local SearXNG AI Search"
server:
secret_key: "PASTE_YOUR_GENERATED_SECRET_KEY_HERE"
bind_address: "0.0.0.0"
port: 8080
limiter: false # Disable rate limiter for local Docker network traffic
search:
safe_search: 0
autocomplete: ""
formats:
- html
- json # Crucial: Open WebUI requires JSON output format enabled
engines:
- name: google
engine: google
use_mobile_ui: false
- name: duckduckgo
engine: duckduckgo
- name: brave
engine: brave
shortcut: br
Step 2: Creating the Unified Docker Compose Stack
In the root of ~/local-ai-stack/, create your docker-compose.yml file:
services:
# 1. Local LLM Runtime
ollama:
image: ollama/ollama:latest
container_name: ai_ollama
restart: unless-stopped
volumes:
- ollama_data:/root/.ollama
environment:
- OLLAMA_KEEP_ALIVE=24h
- OLLAMA_NUM_PARALLEL=2
# Uncomment the deploy block below to enable NVIDIA GPU passthrough:
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
networks:
- ai_internal
# 2. Private Metasearch Engine
searxng:
image: searxng/searxng:latest
container_name: ai_searxng
restart: unless-stopped
volumes:
- ./searxng/settings.yml:/etc/searxng/settings.yml:ro
environment:
- SEARXNG_BASE_URL=http://searxng:8080/
networks:
- ai_internal
# 3. Open WebUI Frontend
open-webui:
image: ghcr.io/open-webui/open-webui:main
container_name: ai_open_webui
restart: unless-stopped
ports:
- "127.0.0.1:3000:8080" # Exposed locally to bind to your reverse proxy
volumes:
- openwebui_data:/app/backend/data
environment:
- OLLAMA_BASE_URL=http://ollama:11434
# Web Search Configuration
- ENABLE_RAG_WEB_SEARCH=True
- RAG_WEB_SEARCH_ENGINE=searxng
- RAG_WEB_SEARCH_RESULT_COUNT=5
- SEARXNG_QUERY_URL=http://searxng:8080/search?q=<query>&format=json
# Local Embeddings for Document RAG
- RAG_EMBEDDING_ENGINE=ollama
- RAG_EMBEDDING_MODEL=nomic-embed-text
depends_on:
- ollama
- searxng
networks:
- ai_internal
networks:
ai_internal:
driver: bridge
volumes:
ollama_data:
openwebui_data:
Launch the containers in detached mode:
docker compose up -d
Step 3: Pulling Required Models and Embeddings
Once the containers are healthy, pull your preferred conversational reasoning model and an embedding model into Ollama:
# Pull the lightweight embedding model for Document RAG
docker exec -it ai_ollama ollama pull nomic-embed-text
# Pull high-performance conversational reasoning models
docker exec -it ai_ollama ollama pull deepseek-r1:8b
docker exec -it ai_ollama ollama pull llama3.2:3b
You can browse the complete directory of community models directly on the official Ollama Model Library.
Step 4: Configuring Open WebUI and Testing Live Search
- Navigate to
http://YOUR_SERVER_IP:3000in your web browser. - The first registered user is automatically designated as the Admin. Create your account credentials.
- Go to Admin Panel > Settings > Web Search:
- Verify that Web Search Engine is set to
searxng. - Confirm the query URL matches
http://searxng:8080/search?q=<query>&format=json. - Set Search Result Count to
3or5to prevent bloating the model context window.
- Verify that Web Search Engine is set to
- Open a new chat session, select
deepseek-r1:8bfrom the model dropdown, and click the Web Search toggle icon next to the chat bar. - Ask a prompt regarding current news or stock updates (e.g., “What were the major tech headlines this morning?”).
Open WebUI will display a status pill showing “Searching the web via SearXNG…”, ingest the relevant links, cite source URLs with clickable footnotes, and synthesize an accurate answer without stale information.
Model Selection and Resource Benchmark Matrix
Depending on your hardware constraints, choose a model that leaves adequate headroom for both system processes and the context window:
| Model | Parameters | VRAM (GPU) | RAM (CPU Fallback) | Best Use Case |
|---|---|---|---|---|
llama3.2:3b |
3.2 Billion | ~2.6 GB | ~4.5 GB | Mini-PCs, ultra-fast queries, low-power home servers. |
qwen2.5:7b |
7.6 Billion | ~5.2 GB | ~8.0 GB | Coding assistance, precise JSON output, multilingual tasks. |
deepseek-r1:8b |
8.0 Billion | ~5.8 GB | ~9.2 GB | Complex mathematical reasoning, logic analysis, deep research. |
nomic-embed-text |
137 Million | ~0.3 GB | ~0.5 GB | Lightning-fast local vector embeddings for RAG & PDF ingestion. |
Troubleshooting Common Configuration Pitfalls
1. “Search Error: Unable to fetch search results from SearXNG”
This typically occurs if the JSON format is disabled inside searxng/settings.yml. Ensure that formats: [html, json] is active and that limiter: false is set. Restart the SearXNG container using docker compose restart searxng.
2. GPU Not Detected Inside the Ollama Container
Run docker exec -it ai_ollama nvidia-smi. If this command outputs “command not found” or fails to initialize, verify that the NVIDIA Container Toolkit is installed on the host and that Docker’s daemon configuration (/etc/docker/daemon.json) includes the nvidia default runtime.
3. Context Window Memory Exhaustion
When searching the web, Open WebUI injects full paragraphs from external sites into the prompt. If you experience out-of-memory container crashes on low-RAM hosts, limit RAG_WEB_SEARCH_RESULT_COUNT to 3 and ensure an adequate swap file is configured following our swap allocation instructions.
Final Thoughts
Combining Ollama, Open WebUI, and SearXNG provides the gold standard in sovereign artificial intelligence: the conversational fluency of top-tier foundation models, the up-to-the-minute freshness of live web search, and 100% data privacy without subscription overhead. Explore the official Open WebUI documentation to discover advanced features like voice interaction, customizable pipeline plugins, and multi-tenant access controls.
Beyond conversational chat, you can connect your local Ollama instance directly into VS Code as an autonomous programming assistant by following our guide on using Cline with Ollama as a free local AI coding agent.
If you also need private conversational intelligence while traveling or completely disconnected from your home server network, check out our guide on Running DeepSeek-R1 and Llama 3 Locally on Android for 100% offline on-device mobile inference.

Leave a Reply