740 words
4 min read

Install Ollama Using Docker Compose

By Docker Captain · CNCF Ambassador · IBM Champion
Cover image for the post 'Install Ollama Using Docker Compose'

This article is for those looking for a detailed and straightforward guide on installing Ollama using Docker Compose.

Ollama is a streamlined, modular framework designed for developing and operating language models locally.

TIP

Architecture Context

Choose self-hosted Ollama when you need local LLM inference with full data privacy — no prompts or responses leave your infrastructure. The OpenAI API or Amazon Bedrock provide managed alternatives with larger model selection and zero GPU maintenance. Self-hosting is justified when data sensitivity prohibits external API calls or when predictable inference costs outweigh the capital expense of GPU hardware.

💾 You can find the repository used in this guide on GitHub.

heyvaldemar
/
ollama-traefik-letsencrypt-docker-compose
Waiting for api.github.com...
0
0
N/A
Waiting...
NOTE

We’ll use Traefik as our reverse proxy. It’ll handle obtaining cryptographic certificates from Let’s Encrypt for your domain names and route requests to the corresponding services based on those domains.

CAUTION

To obtain cryptographic certificates, you will need A-type records in the external DNS zone, which point to the IP address of your server where Traefik is installed. If you have created these records recently, you should wait before starting the installation of the services. Full replication of these records between DNS servers can take from a few minutes to 48 hours or even longer in rare cases.

IMPORTANT

Docker Engine and Docker Compose must be installed on the server.

For a step-by-step guide on installing Docker Engine on Ubuntu Server, see Install Docker Engine and Docker Compose on Ubuntu Server

IMPORTANT

OpenSSH must be installed on the server, and port 22 must be open to be able to connect to the server using the SSH protocol.

To install OpenSSH on the server you can use the command:

Terminal window
sudo apt install openssh-server
NOTE

To connect to the server from a Windows system, you can use tools like PuTTY or MobaXterm.

NOTE

This guide walks you through connecting to a server with the iTerm2 terminal emulator on macOS.

CAUTION

You will need to open the following TCP ports for access to the services:

  • TCP port 80 - to obtain a free cryptographic certificate through the Let’s Encrypt certification center.
  • TCP port 443 - to access the Open WebUI interface in front of Ollama.

We connect to the server on which Ollama is planned to be installed.

Now it is necessary to create networks for your services.

We create a network for Traefik using the command:

Terminal window
docker network create traefik-network

Install Ollama Using Docker Compose - Step 1

We create a network for Ollama using the command:

Terminal window
docker network create ollama-network

Install Ollama Using Docker Compose - Step 2

Next, you need to clone the repository that contains the configuration files, which include all the necessary conditions for Ollama to work.

You can clone the repository using the command:

Terminal window
git clone https://github.com/heyvaldemar/ollama-traefik-letsencrypt-docker-compose.git

Install Ollama Using Docker Compose - Step 3

Navigate to the directory with the repository using the command:

Terminal window
cd ollama-traefik-letsencrypt-docker-compose

Install Ollama Using Docker Compose - Step 4

Next, you need to change the variables in the .env file according to your requirements.

IMPORTANT

The .env file should be in the same directory as ollama-traefik-letsencrypt-docker-compose.yml.

Now let’s start Ollama with the command:

Terminal window
docker compose -f ollama-traefik-letsencrypt-docker-compose.yml -p ollama up -d

Install Ollama Using Docker Compose - Step 5

To access Open WebUI, the web interface for Ollama, go to https://ollama.heyvaldemar.net from your workstation, where ollama.heyvaldemar.net is the domain name of my service. Accordingly, you need to specify your domain name that points to the IP address of your server with the installed Traefik service, which will redirect the request to Ollama.

NOTE

You need to specify the domain name of the service, previously defined in the .env file.

Click on the “Sign up” button.

Install Ollama Using Docker Compose - Step 6

The next step is to provide: your full name, an email address and a password to create an Open WebUI administrator account.

Click on the “Create Account” button.

Install Ollama Using Docker Compose - Step 7

Welcome to Open WebUI.

Please wait for the models listed in your .env file to download; the duration will depend on your internet speed. Once downloaded, you can select any model from the left corner of the interface to start using it.

Install Ollama Using Docker Compose - Step 8

To access the Traefik control panel, go to https://traefik.ollama.heyvaldemar.net from your workstation, where traefik.ollama.heyvaldemar.net is the domain name of my service. Accordingly, you need to specify your domain name that points to the IP address of your server with the installed Traefik.

NOTE

You need to specify the domain name of the service, previously defined in the .env file.

Enter the username and password previously set in the .env file, and click the “OK” button.

Install Ollama Using Docker Compose - Step 9

Welcome to the Traefik control panel.

Install Ollama Using Docker Compose - Step 10


Vladimir Mikhalev

Docker CaptainCNCF AmbassadorIBM Champion

The Verdict — production-tested analysis on YouTube.

The Verdict

Inconvenient truths about shipping in the AI era

Container security, platform engineering, and the agentic shift — tested in production, argued without the hype. The verdict reaches your inbox the moment there's one worth sending.

Related Posts

Same category
  1. 1
    Cypress Failures Are Untrusted Input to the AI Agent Triaging Them
    AI & MLOps · A customer's note in a Cypress failure message reached an AI triage agent's prompt. One of three open models acted on it in 156 of 165 triages. The walls held.
  2. 2
    AI-BOM at Admission — The Cluster Refused a Signed Model for Its Licence
    AI & MLOps · An AI-BOM read at admission. Everything crosses the air gap as one signed file, and a signed model is refused for its licence. CycloneDX, Kyverno, cosign.
  3. 3
    Prompt Injection Evals — Six Models, One Boundary, Nothing Left the Company
    AI & MLOps · Prompt injection evals on six small models. They acted on hidden instructions from never to half the time, and zero data left. Gate the boundary.
  4. 4
    AI Agent Governance — One Engineer, Over a Hundred Repositories and the Decisions No Agent Makes
    AI & MLOps · AI agent governance for one engineer and 100+ repositories. What the agents decide, what they never do, and the documented auto-merge that merges red checks.

Random Posts

Random
  1. 1
    Trim Windows 10 Startup: Task Manager and the Two Startup Folders
    SysAdmin & IT Pro · Where Windows 10 keeps startup entries: Task Manager's Startup tab, the per-user Startup folder and the all-users one, with the exact paths.
  2. 2
    Install Docker Engine and Docker Compose on Ubuntu Server
    DevOps & Cloud · Learn how to install Docker Engine and Docker Compose on Ubuntu Server. Follow a clear, step-by-step guide to get Docker running quickly and securely.
  3. 3
    Terraform MCP server GA: the Apply Gate your auditor will ask about
    DevOps & Cloud · HashiCorp's Terraform MCP server is GA and IBM Bob can write production IaC. ENABLE_TF_OPERATIONS separates a safe assistant from autonomous apply.
  4. 4
    Configure Exchange Server 2010
    SysAdmin & IT Pro · Complete guide to configuring Exchange Server 2010. Learn mailbox setup, certificates, DNS, email policies, and secure mail delivery—step by step.
Install Ollama Using Docker Compose
https://heyvaldemar.com/install-ollama-using-docker-compose/
Author
Vladimir Mikhalev
Published
2024-09-27
Updated
2026-10-06
License
CC BY-NC-SA 4.0