Running Ollama in Docker keeps it in its own container, alongside other containers such as a chat front end. This guide follows Ollama's official Docker documentation.
If you'd rather install Ollama directly, see how to install Ollama on Linux. To check your graphics card is supported before you start, see how to check your GPU works with Ollama.
What you need
A Linux PC (or a Linux server) with Docker installed
For GPU acceleration: a supported NVIDIA or AMD graphics card and its driver
Enough disk space for models, which are stored in a Docker volume
Ollama's Docker guide gives Linux commands. On Windows, for running Linux AI tools with GPU access, see how to set up WSL2 for GPU local AI.
Option 1: CPU only
The simplest command starts Ollama without GPU access:
docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
Here -v ollama:/root/.ollama mounts a Docker volume called ollama at /root/.ollama inside the container, and -p 11434:11434 publishes Ollama's API port.
Option 2: NVIDIA GPU
Ollama says you first need the NVIDIA Container Toolkit. On Debian or Ubuntu-based systems, Ollama's guide configures NVIDIA's repository, then installs the package:
sudo apt-get update
sudo apt-get install -y nvidia-container-toolkit
Ollama also gives Yum/Dnf steps for other distributions. Next, configure Docker to use the NVIDIA runtime and restart Docker:
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker
Then start the container with all GPUs:
docker run -d --gpus=all -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
Ollama notes that on NVIDIA JetPack systems, it can't detect the JetPack version automatically, so you pass JETSON_JETPACK=5 or JETSON_JETPACK=6 to the container.
Option 3: AMD GPU (ROCm)
For AMD graphics cards, Ollama's guide uses the rocm image tag and passes the GPU devices into the container:
docker run -d --device /dev/kfd --device /dev/dri -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama:rocm
Option 4: Vulkan
Ollama says Vulkan is bundled into the standard ollama/ollama image and enabled by default when the container can access the GPU devices:
docker run -d --device /dev/kfd --device /dev/dri -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
Use OLLAMA_VULKAN=0 to turn Vulkan off, or GGML_VK_VISIBLE_DEVICES to choose specific Vulkan devices. For how the different back ends compare, see CUDA vs ROCm vs Vulkan for local AI.
Step 5: Run a model
With the container running, use docker exec to run Ollama's own command inside it. Ollama's example is:
docker exec -it ollama ollama run llama3.2
The first run downloads the model into the volume. More models are listed in the Ollama library. To check whether the model is actually using your graphics card, see how to check Ollama is using your GPU.
Using the API and other apps
Because port 11434 is published, apps on the same PC can reach Ollama at http://localhost:11434, just as with a native install. That includes front ends such as Open WebUI; see how to install Open WebUI with Ollama, and for code, how to use Ollama's OpenAI-compatible API. If you want other devices on your network to use it, see how to share Ollama on your local network, and think about security before exposing the port.
Updating
Ollama's Docker page doesn't cover updates. With standard Docker commands, you can pull the latest image, then stop and remove the container and recreate it with the same docker run command, which mounts the same ollama volume:
docker pull ollama/ollama
docker stop ollama
docker rm ollama
Our verdict
Docker is a tidy way to run Ollama on Linux: one command for CPU, the NVIDIA Container Toolkit plus --gpus=all for NVIDIA cards, and the rocm image for AMD. Use the named volume from Ollama's commands, and check the GPU is being used before you blame the container for slow answers.