Deploying Llama-3 & DeepSeek-R1 Locally with Docker and Ollama
π‘ Developer Takeaways
Set up a containerized local Dify stack and integrate it with Ollama to run high-performance AI models offline.
1. Why Private Local Deployments?
Relying on external cloud APIs poses severe data privacy risks for core enterprise databases and contracts. Furthermore, scale deployments face heavy API pricing. Local deployments deliver 100% compliance with zero token runtime costs. This guide sets up Ollama and Dify in isolated local subnets.
2. Running Local Inference with Ollama
Ollama handles GPU scheduling and model quantization natively.
A. Installing Ollama
Install Ollama on your host server. On Linux, run:
curl -fsSL https://ollama.com/install.sh | sh
B. Pulling the Weights
Pull reasoning-focused models like DeepSeek-R1:8b or Llama-3-70b-quantized:
ollama run deepseek-r1:8b
Confirm the model loads and executes locally, utilizing your dedicated GPU vRAM.
3. Deploying Dify with Docker Compose
We deploy Dify's frontend, API servers, Postgres, and Redis services inside docker containers:
git clone https://github.com/langgenius/dify.git
cd dify/docker
cp .env.example .env
docker compose up -d
Access the web console at http://localhost and set up your initial admin credentials.
4. Bridging Dify Containers to host-level Ollama
Because Dify runs inside isolated docker network bridges, pointing Dify's settings to http://localhost:11434 triggers connection errors.
Configuring the Endpoint:
- Windows/macOS: Set Dify's Ollama API endpoint to:
http://host.docker.internal:11434. - Linux: Set the endpoint to the bridge host IP (typically
http://172.17.0.1:11434) and edit your host environment variables to setOLLAMA_HOST=0.0.0.0to accept network connections.
Once connected, index your enterprise manuals in local RAG datasets, enabling secure, offline AI assistance.
// Typical execution logic
// Book a diagnostic session to access our complete Git repositories
console.log("Loading module: $Local Hosting...");
console.log("Configuring agent pipeline: $Deploying Llama-3 & DeepSeek-R1 Locally with Docker and Ollama...");
console.log("Dependencies active. Pipeline initializing...");
// TODO: Custom code hooks for wolaizuo solutions. * This tutorial is developed by wolaizuo technical team. If you prefer a professional team to build this workflow for you, or require system integrations (ERP/CRM), feel free to schedule a free 15-minute diagnostic call with us.