0
Programming Foundations
Phase 0Module 10 of 14

Docker

AI apps have complex dependencies. Docker solves 'it works on my machine' with reproducible environments.

A shipping container — loads and unloads the same way everywhere, no matter what's inside.

Visual Workflows

Start here — study each diagram, then use + / to zoom if needed.

Overview

100%
Loading diagram...

Scroll inside the frame · use + / − to zoom

100%
Loading diagram...

Scroll inside the frame · use + / − to zoom

Key Takeaways

  • 1.Docker packages your app and dependencies into a portable container — runs identically on your laptop and in production.
  • 2.Images are blueprints, containers are running instances.
  • 3.Dockerfile defines the build.
  • 4.Docker Compose runs multiple services together.

Real Example

Scenario

Your FastAPI app works locally but crashes on the production server due to missing dependencies.

What you would do

Dockerize it — Dockerfile installs exact deps, docker-compose runs API + ChromaDB together. Same result everywhere.

Practice Task

Run docker run hello-world. Then run docker ps -a to see the container. If Docker is not installed, read the Docker diagram and write down the 4 key commands you will use later.

Commands

Commands to Remember

  • docker build -t name . # build an image from Dockerfile
  • docker run -p 8000:8000 name # run container and map port 8000
  • docker run --env-file .env name # pass secrets via env file at runtime
  • docker-compose up -d # start all services in the background
  • docker logs container_id # view logs from a container
  • docker ps # list currently running containers

Cheat Sheet

Quick recap

quick ref
  • Image = blueprint · Container = running instance
  • Dockerfile defines build steps · docker build creates image
  • docker run starts a container · docker-compose runs multiple services
  • Pass secrets via --env-file at runtime — never in Dockerfile
  • Use .dockerignore to keep images small
  • docker logs and docker exec for debugging

Common Mistakes

  • API keys in Dockerfile
  • No .dockerignore — huge images
  • Running as root in production