Let’s create our own local ChatGPT.
In the rapidly evolving landscape of natural language processing, Ollama stands out as a game-changer, offering a seamless experience for running large language models locally. If you’re eager to harness the power of Ollama and Docker, this guide will walk you through the process step by step.
Why Ollama and Docker?
Think of Ollama as your personal LLM concierge. It sets up and manages your chosen model, making it readily available for your creative endeavors. Docker, on the other hand, acts as the friendly neighborhood containerizer, ensuring a smooth, isolated environment for your LLM to operate in. Together, they create a dream team for hassle-free LLM exploration.
Benefits of using Ollama and Docker together
- Simplicity: Ditch the complex configurations and dependencies. Docker handles the heavy lifting, letting you focus on what matters – interacting with your LLM.
- Isolation: Multiple LLMs? No problem! Docker keeps them neatly separated, preventing any unwanted intermingling.
- Portability: Take your LLM playground anywhere. Docker containers are platform-agnostic, so your AI companion can travel across Linux, macOS, and even Windows.
- Scalability: Need more LLM power? No worries! Docker lets you scale your environment by running multiple containers with ease.
Getting started:
- Install Docker: Download and install Docker Desktop for Windows and macOS, or Docker Engine for Linux.
- Grab your LLM model: Choose your preferred model from the Ollama library (LaMDA, Jurassic-1 Jumbo, and more!).
- Download the Ollama Docker image: One simple command (
docker pull ollama/ollama
) gives you access to the magic. - Run the Ollama container: Customize it for your CPU or Nvidia GPU setup using the provided instructions.
- Open the Ollama web interface: Navigate to http://localhost:11434 and say hello to your LLM!
Beyond the basics:
- Send text prompts and receive creative responses. Imagine LLM-powered poems, code generation, and even scriptwriting!
- Fine-tune your model on your own data. Make your LLM a true reflection of your unique voice and interests.
- Explore a variety of LLM tasks: Translation, question-answering, code completion – the possibilities are endless.
Installing Ollama with Docker
CPU Only
To get started with the CPU-only version, simply run the following Docker command:
docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama

Nvidia GPU
Install the NVIDIA Container Toolkit:
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey \
| sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list \
| sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' \
| sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt-get update
Configure Docker to use Nvidia driver:
sudo apt-get install -y nvidia-container-toolkit
Start the container:
docker run -d --gpus=all -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
Running Models Locally
Now that Ollama is up and running, execute the following command to run a model:
docker exec -it ollama ollama run llama2
You can even use this single-liner command:
$ alias ollama='docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama && docker exec -it ollama ollama run llama2'
Let’s run a model and ask Ollama to create a docker compose file for WordPress.
docker exec -it ollama ollama run llama2
pulling manifest
pulling 22f7f8ef5f4c... 100% ▕██████████████████████████████████████████████▏ 3.8 GB
pulling 8c17c2ebb0ea... 100% ▕██████████████████████████████████████████████▏ 7.0 KB
pulling 7c23fb36d801... 100% ▕██████████████████████████████████████████████▏ 4.8 KB
pulling 2e0493f67d0c... 100% ▕██████████████████████████████████████████████▏ 59 B
pulling 2759286baa87... 100% ▕██████████████████████████████████████████████▏ 105 B
pulling 5407e3188df9... 100% ▕██████████████████████████████████████████████▏ 529 B
verifying sha256 digest
writing manifest
removing any unused layers
success
>>> Write a docker compose file for WordPress
⠧
Sure, here is an example `docker-compose.yml` file for running WordPress:
```
version: '3'
services:
wordpress:
image: woorkshop/wordpress:latest
ports:
- "80:80"
volumes:
- ./wp:/var/www/html
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: username
WORDPRESS_DB_PASSWORD: password
WORDPRESS_SITE_URL: http://localhost
WORDPRESS_SITE_WIDTH: 100%
WORDPRESS_SITE_HEIGHT: 100%
depends_on:
- db....
Let's go through the file line by line:
* `version`: This line specifies the version of Docker Compose that the file is written for. In this
case, we are using version 3.
* `services`: This line defines a service called "wordpress".
* `image`: This line specifies the Docker image to use for the WordPress container. In this case, we are
using the official Woorkshop/WordPress image.
* `ports`: This line maps port 80 from the host machine to port 80 in the container. This allows us to
access the WordPress site through our web browser.
* `volumes`: This line mounts a directory on the host machine ("./wp") to the `/var/www/html` directory
inside the WordPress container. This allows us to store WordPress files outside of the container, but
make them accessible to the container.
* `environment`: This line defines environment variables that will be available inside the WordPress
container. In this case, we are setting the following variables:
+ `WORDPRESS_DB_HOST`: The hostname of the database server.
+ `WORDPRESS_DB_USER`: The username to use for database authentication.
+ `WORDPRESS_DB_PASSWORD`: The password to use for database authentication.
+ `WORDPRESS_SITE_URL`: The URL of the WordPress site.
+ `WORDPRESS_SITE_WIDTH`: The width of the WordPress site (in percentages).
+ `WORDPRESS_SITE_HEIGHT`: The height of the WordPress site (in percentages)....
Ollama WebUI using Docker Compose
If you’re not a CLI fan, then you might have to look at Ollama-webui project repository
git clone https://github.com/ollama-webui/ollama-webui
cd ollama-webui
version: '3.6'
services:
ollama:
# Uncomment below for GPU support
# deploy:
# resources:
# reservations:
# devices:
# - driver: nvidia
# count: 1
# capabilities:
# - gpu
volumes:
- ollama:/root/.ollama
# Uncomment below to expose Ollama API outside the container stack
# ports:
# - 11434:11434
container_name: ollama
pull_policy: always
tty: true
restart: unless-stopped
image: ollama/ollama:latest
ollama-webui:
build:
context: .
args:
OLLAMA_API_BASE_URL: '/ollama/api'
dockerfile: Dockerfile
image: ollama-webui:latest
container_name: ollama-webui
depends_on:
- ollama
ports:
- 3000:8080
environment:
- "OLLAMA_API_BASE_URL=http://ollama:11434/api"
extra_hosts:
- host.docker.internal:host-gateway
restart: unless-stopped
volumes:
ollama: {}
Access the Ollama WebUI
Open Docker Dashboard > Containers > Click on WebUI port

Accessing WebUI

Pulling a Model
Mistral is a 7.3B parameter model, distributed with the Apache license. It is available in both instruct (instruction following) and text completion.

Update: This model has been updated to Mistral v0.2. The original model is available as mistral:7b-instruct-q4_0

Resources at your fingertips:
- Ollama Docker image documentation: https://github.com/jmorganca/ollama/blob/main/Dockerfile
- Ollama library: https://github.com/jmorganca/ollama
- Ollama GitHub repository: https://github.com/jmorganca/ollama/blob/main/.gitmodules
Keep Reading
-
Testcontainers and Playwright
Discover how Testcontainers-Playwright simplifies browser automation and testing without local Playwright installations. Learn about its features, limitations, compatibility, and usage with code examples.
-
Getting Started with the Low-Cost RPLIDAR Using NVIDIA Jetson Nano
Conclusion Getting started with low-code RPlidar with Jetson Nano is an exciting journey that can open up a wide range of possibilities for building robotics projects. In this blog post, we covered the basic steps to get started with low-code RPlidar with Jetson Nano, including setting up ROS, installing the RPlidar driver and viewing RPlidar…
-
Docker and Wasm Containers – Better Together
Learn how Docker Desktop and CLI both manages Linux containers and Wasm containers side by side.
-
5 Minutes to Kubernetes MCP Server using Docker MCP Tookit
Have you ever wished you could manage your Kubernetes clusters more easily without switching between multiple tools and terminals? Imagine managing K8s clusters using simple natural language commands instead of memorizing dozens of kubectl incantations. Well, the wait is over. Docker’s Model Context Protocol (MCP) Toolkit is revolutionizing how we interact with Kubernetes, bringing AI-powered…
-
How to Choose the Right APM Tool: A Comparison of the Top Solutions in 2025
In the era of cloud-native apps, distributed systems, and microservices, application performance monitoring (APM) is no longer optional—it’s essential. The right APM tool helps businesses deliver fast, reliable, and efficient user experiences, detect issues proactively, and optimize system performance across complex environments. But with so many APM tools in the market, each offering a wide…
-
How Innovative Health Solutions Are Transforming Lives
Innovative health solutions change lives in remarkable ways. From new treatments to accessible virtual care, advancements today offer options that were unimaginable just a decade ago. This year brought significant progress across medicine, technology, and personalized health management. Communities worldwide feel the impact locally—bringing hope closer to home. In Newcastle, innovation meets accessibility through breakthroughs…