RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Eruo Fredoline
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
  1. >
  2. Home
  3. /Learn
  4. /How-to
  5. /How to persist Ollama data in Docker
HOW-TO · SET

How to persist Ollama data in Docker

intermediate·10 min·By Eruo Fredoline
Target environment
Ubuntu 24.04 · Ollama 0.4.xWindows 11 · Ollama 0.4.xmacOS 15 · Ollama 0.4.x
PREREQUISITES

Ollama running in Docker container

What this does

Maps the container's model storage directory to a host filesystem path so models, history, and configuration survive container restarts and rebuilds. After this guide the Ollama data directory is backed by a persistent volume.

Steps

  1. Identify the default models directory inside the container. Ollama stores models at /root/.ollama/models by default.

    docker exec ollama ls /root/.ollama/models
    

    Expected output: Directory listing showing downloaded model folders.

  2. Create the host directory for persistence.

    mkdir -p ~/ollama-data
    

    Expected output: Quiet success.

  3. Stop and remove the existing container.

    docker stop ollama && docker rm ollama
    

    Expected output: Container ID printed for both commands.

  4. Launch Ollama with a bind mount for the models directory.

    docker run -d \
      --name ollama \
      -p 11434:11434 \
      -v ~/ollama-data:/root/.ollama/models \
      ollama/ollama
    

    Expected output: Full container ID string.

  5. Store the Docker Compose manifest for repeatability.

    services:
      ollama:
        image: ollama/ollama:latest
        container_name: ollama
        ports:
          - "11434:11434"
        volumes:
          - ~/ollama-data:/root/.ollama/models
        restart: unless-stopped
    
    docker compose up -d
    

Verification

docker exec ollama ls /root/.ollama/models
# Expected: Directory listing identical to the host ~/ollama-data contents

Common failures

  • Error: no such container: ollama — The container was not named ollama when created. Find the name with docker ps -a.
  • Models not found after recreate — The host path was empty at first run. Always stop the container before removing it.
  • Permission denied — Run chmod -R 755 ~/ollama-data or adjust ownership.
  • Container exits immediately — The bind mount syntax is incorrect. Use an absolute path.
  • Port already allocated — Port conflict with another process. Change the host port to 11435:11434.
  • Volume mount not propagating — On macOS Docker Desktop, file changes may be delayed. Use docker restart ollama to force re-mount.

Related guides

  • How to install Open WebUI with Docker
  • How to configure Open WebUI with Ollama backend
  • Course Local AI Fundamentals
RELATED GUIDES
SET
How to configure Open WebUI with Ollama backend
SET
How to install Open WebUI with Docker
← All how-to guidesCourses →