Every time you type into a hosted AI chatbot, your words leave your device and land on someone else’s servers. For a lot of people and a lot of tasks, that’s fine. But for anything sensitive — or if you just want to tinker without a per-message bill — there’s a genuinely empowering alternative: run an open-weight AI model locally, inside a container, on your own hardware. Do that, and nothing you type ever leaves your machine.
This guide shows you how to run AI models locally with Docker — the concept, a concrete walkthrough with the real commands, and (crucially) an honest look at what your computer can and can’t handle. It’s the hands-on companion to what a container is and the practical answer to the privacy questions in is DeepSeek safe to use?

The Idea: A Model Server in a Box
The pattern is simpler than it sounds. To run an AI model yourself, you need a model server — a program that loads the model’s weight files and exposes an API you can send prompts to. You then talk to it from your terminal or a local web page.

Running that server in a container is the clean way to do it. Remember the two-part distinction from the container basics: an image is the read-only blueprint, and a container is a running instance of it. Instead of wrestling with Python versions and GPU drivers by hand, you pull a ready-made image, run it as a container, and the whole fiddly environment comes pre-assembled and reproducible — and you can throw it away cleanly when you’re done.
The friendliest tool for this is Ollama, so we’ll use it as the main example.
Step 1: Run the Model Server in a Container
Ollama publishes an official Docker image (ollama/ollama). One command starts it:
docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollamaHere’s what each part does — no magic:
docker runpulls the image (if you don’t already have it) and starts a container from it.-druns it detached, in the background, so your terminal is free.-p 11434:11434maps port 11434 on your machine to port 11434 inside the container — that’s the port Ollama’s API listens on. (The order isHOST:CONTAINER.)-v ollama:/root/.ollamastores downloaded models in a named volume so they survive a container restart — you don’t want to re-download gigabytes every time.--name ollamajust gives the container a friendly name.
That’s the entire “run a model server locally” loop.
Step 2: Download and Chat With a Model
With the server running, you pull a model and talk to it. For example:
docker exec -it ollama ollama run deepseek-r1:8bThis runs the ollama run command inside the container, downloading an 8-billion-parameter distilled DeepSeek model (the first time) and dropping you into a chat prompt. Swap in another model name — llama3, mistral, qwen, gemma — and you’ve got a different brain, all running locally. Because the server also exposes an OpenAI-compatible API on port 11434, any app that speaks that format can point at your local model instead of a paid cloud endpoint.
Step 3 (Optional): Add a Private ChatGPT-Style Interface
Chatting in a terminal is fine, but you can have the familiar web-chat experience — entirely on your own machine — by pairing Ollama with Open WebUI. The common approach is a small Docker Compose file that declares both containers (the Ollama server + the web UI) and wires them together, so a single docker compose up brings up a private, ChatGPT-like interface in your browser. (Compose is the tool for running multi-container stacks with one command — a topic worth its own guide.)
The result: a polished local AI chat, no account, no data leaving your computer.
The Honest Part: What Your Machine Can Actually Run
Here’s where a lot of “run AI locally!” guides quietly mislead you. Model size drives memory need, and the biggest models are firmly data-center hardware.

- The full DeepSeek-R1 (671 billion parameters) needs roughly 350 GB or more of VRAM even compressed to 4-bit — that’s a cluster of high-end datacenter GPUs. It will not run on your laptop. Full stop.
- What you actually run at home are distilled and quantized models — smaller versions that keep much of the capability. (Distillation is the trick of teaching a small model to imitate a big one; we cover it in AI model distillation explained.) DeepSeek released distilled variants from 1.5B up to 70B for exactly this.
Rough guide to what fits:
| Model size | Approx. memory (4-bit) | Runs on |
|---|---|---|
| 1.5B | ~2.3 GB | almost any modern machine / small GPU |
| 7–8B | ~5.5–8 GB | a decent laptop (8 GB+) |
| 32B | ~18 GB | a high-end GPU (e.g. RTX 4090-class) |
| 671B (full) | ~350 GB+ | a datacenter GPU cluster — not you |
A useful rule of thumb (Ollama’s own): at least 8 GB of RAM for 7B models, 16 GB for 13B, and 32 GB for ~33B, with quantization (like Q4) roughly halving the footprint. A GPU makes it much faster, but small models run acceptably on CPU too. Match the model to your machine and local AI is genuinely great; expect the flagship on a laptop and you’ll have a bad time.
Why Do This At All?
Four real reasons:
- Privacy — the headline. With a hosted app, your prompts go to a company’s servers. When you self-host the open weights, the data stays on your machine — nothing is sent to a third party. This is the load-bearing distinction: “is the DeepSeek app safe with my data?” is a completely different question from “is running DeepSeek’s open weights on my own hardware safe?” The second keeps your text local, by architecture, not by promise.
- Cost. No per-token bill for endless experimentation — you pay once, in hardware and electricity.
- Offline. It works with no internet connection at all.
- Control. You pin exact model versions; no provider can silently change or retire the model out from under you.
Beyond Ollama: When You Outgrow the Easy Path
Ollama is the on-ramp. Two heavier-duty routes when you need more:

- vLLM is a high-throughput serving engine built for performance (its “PagedAttention” is the claim to fame). It ships an OpenAI-compatible server and an official container image — the right tier when you’re serving a model to real traffic rather than poking at it solo.
- Docker Model Runner is Docker’s own feature (introduced in 2025) that lets you manage models with familiar Docker verbs —
docker model pull,docker model run— treating models as standard artifacts and using engines like llama.cpp or vLLM under the hood. (It’s evolving quickly, so check the current docs for specifics.)
But you don’t need either to start. One docker run, one model pull, and you’ve got private AI on your own machine — the containers-and-DevOps skills from this cluster, put directly to work.
❓ Frequently Asked Questions
Can I run AI models locally with Docker for free? Yes. Tools like Ollama are free and open-source, the models (Llama, DeepSeek’s open weights, Mistral, and others) are free to download, and Docker Engine is free. Your only real cost is hardware and electricity — there’s no per-message API bill.
Is it actually private to run AI locally? Yes, and that’s the main appeal. When the model runs on your own hardware, your prompts never leave your machine — there’s no third-party server receiving them. This is fundamentally different from a hosted app, where your text is sent to the provider. Running the open weights locally is private; using the hosted app is not the same thing.
What hardware do I need to run AI models locally? It depends entirely on model size. Small models (1.5B–8B parameters) run on an ordinary laptop with 8–16 GB of RAM. A 32B model wants a high-end GPU (~18 GB). The full 671B DeepSeek-R1 needs a datacenter GPU cluster (~350 GB+ of memory) and won’t run on a personal computer — use a distilled/quantized version instead.
Can I run the full DeepSeek-R1 on my laptop? No. The full 671-billion-parameter model requires roughly 350 GB or more of VRAM even when compressed. What you can run on a laptop is a distilled version (1.5B–8B), which keeps much of the reasoning ability in a far smaller package.
Do I need to know Docker deeply to do this? Not really. If you understand that an image is a blueprint and a container is a running instance (from our container basics), and you can copy one docker run command, you can get a local model running. Deeper Docker skills help when you start wiring up multi-container stacks with Compose.
📚 Keep Learning
- What Is a Container? — the foundation this walkthrough builds on.
- Is DeepSeek Safe to Use? — why self-hosting is the private option, in depth.
- AI Model Distillation Explained — how the small models that do fit on your machine get so capable.
📚 Recommended Resources
Disclosure: some links below are Amazon affiliate links. If you buy through them, I earn a small commission — at no extra cost to you — which helps keep this site running.
Docker Deep Dive
Nigel Poulton · Book · ~$30 on Amazon
Once you’ve run your first model in a container, this is the book that turns copy-pasted commands into real understanding. It’s the standard, best-selling Docker guide — clear and hands-on — covering images, containers, volumes, and networking, so you can confidently go beyond a single docker run.
Hands-On Machine Learning with Scikit-Learn, Keras & TensorFlow
Aurélien Géron · Book · ~$70 on Amazon
Running a model locally is more satisfying when you understand what’s inside it. This is the best practical reference for how these models actually work — from the fundamentals up to modern deep learning — so “run AI on my machine” becomes “understand the AI I’m running.”