Docker keeps the Ollama server, its libraries, and the model store inside a container, off the host system. With the NVIDIA Container Toolkit installed, the container can use the host GPU just like a native install.
What you need
- Docker installed and running on a Linux host
- NVIDIA Container Toolkit installed, for GPU use
- About 10 GB of free disk space for the image and a first model
Step 1: Start the container
Run: docker run -d –gpus=all -v ollama:/root/.ollama -p 11434:11434 –name ollama ollama/ollama. The –gpus=all flag gives the container the GPUs, the named volume keeps models across container upgrades, and port 11434 is the API.
Step 2: Pull and run a model inside it
Run docker exec -it ollama ollama pull llama3.2 and then docker exec -it ollama ollama run llama3.2. The commands run inside the container, while the model files land in the named volume.
Step 3: Verify the GPU is used
Run docker exec -it ollama ollama ps. The PROCESSOR column should read 100% GPU when the model fits in VRAM. A split such as 30%/70% CPU/GPU means part of the model spilled to the CPU.
Worked example: Ollama in Docker with one GPU
The table below is a synthetic example. The docker command and the PROCESSOR readings come from the cited Docker guide; the model is illustrative.
| Check | Command | Expected result |
|---|---|---|
| Start | docker run -d –gpus=all … ollama/ollama | Container running |
| Pull | docker exec -it ollama ollama pull llama3.2 | success |
| GPU | docker exec -it ollama ollama ps | PROCESSOR 100% GPU |
Expected result (UNTESTED). the container starts, the model pulls inside it, and ollama ps shows 100% GPU. This check was not run live; the commands and readings come from the cited Docker guide.
Limits
- Without the Container Toolkit, the container sees no GPU and runs on CPU.
- Docker Desktop on macOS has no Apple GPU access, so Ollama in Docker there is CPU-only.
- Without the named volume, a new container downloads every model again.
- Keep the published port on 127.0.0.1; the API has no authentication.
