Your FastAPI agent runs perfectly on your machine. But "works on my machine" doesn't scale to production or your team's machines. Docker solves this fundamental problem by packaging your agent, its dependencies, and its runtime into a container that runs identically everywhere—your laptop, a teammate's Mac, or a cloud server.
Before you experience the power of containerization through AI collaboration, you need to understand what Docker actually is. This chapter walks you through installation and initial setup manually, building the mental model you'll need to optimize containers and debug issues later.
Before diving into Docker, understand the problem it solves and why it's become essential for deploying AI services.
Your FastAPI agent from Module 6 works on your laptop. But to make it useful, you need to run it somewhere accessible—a server in the cloud, your company's data center, or a colleague's machine. This is where things break:
Every difference is a potential bug. The server says "Module not found." You say "But it works on my machine!"
Option 1: Manual Setup (Fragile) SSH into the server, install Python, pip install dependencies, copy files, configure environment variables, hope nothing changed since yesterday. Problems: Slow, error-prone, not reproducible. Works until someone updates a system package.
Option 2: Virtual Machines (Heavy) Package the entire operating system—kernel, libraries, your application—into a VM image. Run the VM on any hypervisor (VMware, VirtualBox, cloud providers).
Problems: Each VM needs its own OS (gigabytes of storage), boots in minutes, wastes RAM running duplicate kernels. Running 10 services means 10 operating systems.
Option 3: Containers (Lightweight) Package your application and dependencies, but share the host kernel. No duplicate operating system. Start in milliseconds. Use megabytes instead of gigabytes.
Key insight: Containers share the host's kernel. They're isolated processes, not full operating systems. This makes them:
Your AI agent has specific requirements:
Containers solve all of these by freezing your entire environment into an immutable, portable package. When you deploy to the cloud, you're not hoping the server is configured correctly—you're shipping the exact environment that works.
If you're new to cloud computing, here's the essential context:
Cloud providers (AWS, Google Cloud, Azure, DigitalOcean) rent you servers by the hour. These servers run Linux. You deploy your application to these servers. Without containers: You configure each server manually, install dependencies, copy files. Different servers drift out of sync. With containers: You build once, push to a registry (like Docker Hub), and pull onto any server. The container is identical everywhere. Kubernetes (Sub-module 2) orchestrates many containers across many servers—handling load balancing, failover, and scaling. But first, you need to know how to build and run a single container. That's what Docker teaches you.
Check that your system meets these baseline requirements:
If your machine is underpowered, you have options:
Before installing anything, understand what we're installing. Docker has three essential components:
This is the core. The Docker Engine is a lightweight process that runs on your operating system and:
On macOS and Windows, you can't install Docker Engine directly (it's Linux-native). Docker Desktop solves this by:
Inside Docker Engine runs containerd, a lower-level component that actually:
On Linux, the stack is simpler (no VM needed):
Supported versions: macOS 11.0 (Big Sur) and later
Step 1: Download Docker Desktop Visit Docker's official download page and click the macOS download button. You'll see two options:
Step 2: Install Docker Desktop
Step 3: Launch Docker
Supported versions: Windows 10 (21H2 and later) or Windows 11
Prerequisites check: Docker Desktop on Windows requires Hyper-V. Check if it's enabled:
Expected output:
If State is "Disabled", you need to enable Hyper-V first:
Restart your computer when prompted.
Step 1: Download Docker Desktop Visit Docker's official download page and click the Windows download button. This downloads Docker Desktop Installer.exe.
Step 2: Install
Step 3: Launch Docker
Supported distributions: Ubuntu 18.04+, Fedora, Debian, CentOS, etc.
Ubuntu/Debian:
Fedora/RHEL:
No matter your OS, verify Docker installed correctly by checking the version:
Key confirmation: You see both Client and Server sections. If you see only "Client" without "Server," Docker Engine isn't running. Restart Docker Desktop and try again.
Now test that the entire system works end-to-end:
Congratulations: You've just created and run your first container. This command validates that Docker Engine is running, network connection works, image pulling works, and container creation works.
For AI services, we recommend these resource settings in Settings > Resources:
On Linux, specify limits at runtime: