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·Fredoline Eruo
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. /Courses
  5. /First Local Chatbot
  6. /Ch. 14
First Local Chatbot

14. Docker Deployment

Chapter 14 of 15 · 20 min
KEY INSIGHT

Docker containers cannot access host services by default; `host.docker.internal` bridges the gap but requires platform-specific configuration.

Create Dockerfile:

FROM python:3.11-slim

WORKDIR /app
RUN pip install --no-cache-dir fastapi uvicorn httpx python-multipart

COPY app/ ./app/

EXPOSE 8000

CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

Create docker-compose.yml:

version: "3.8"
services:
  chatbot:
    build: .
    ports:
      - "8000:8000"
    volumes:
      - ./app:/app/app
    environment:
      - OLLAMA_BASE=http://host.docker.internal:11434
    network_mode: host  # needed for host.docker.internal on Linux

The key trick is host.docker.internal, which lets the container reach the host's Ollama. On Linux, host.docker.internal requires network_mode: host. On macOS and Windows, Docker Desktop handles it automatically.

Build and run:

docker build -t chatbot .
docker run -p 8000:8000 chatbot

A failure mode: on Linux, host.docker.internal is not in /etc/hosts by default. Add it in the Dockerfile:

RUN echo "172.17.0.1 host.docker.internal" >> /etc/hosts

Find the correct gateway IP with ip route | grep docker on the host.

Local verification checkpoint

Run the smallest example from this chapter in a local workspace and record the package version, runtime, data path, and observed output. If the result depends on model size, vector count, CPU/GPU backend, or available memory, note that constraint beside the exercise so the lesson remains reproducible.

Local verification checkpoint

Run the smallest example from this chapter in a local workspace and record the package version, runtime, data path, and observed output. If the result depends on model size, vector count, CPU/GPU backend, or available memory, note that constraint beside the exercise so the lesson remains reproducible.

EXERCISE

Build the Docker image, start the container, and access the chatbot at http://localhost:8000. Verify streaming works from inside the container.

← Chapter 13
LAN Deployment
Chapter 15 →
Chatbot Project Wrap-up