Containers & Docker

Containers package code and all its dependencies into a single unit. This solves the classic problem: "It works on my machine, but breaks in production."

đŸ—ī¸ VM vs. Containers

Virtual Machine (Heavy)

App A
Libs / Bins
Guest OS (GBs)
Hypervisor + Host Infrastructure

Includes a full Operating System. Slow to boot. Uses lots of RAM.

Container (Light)

App A
Libs / Bins
Container Engine
Host OS + Infrastructure

Shares the Host OS Kernel. Boots in milliseconds. Very lightweight.

đŸ•šī¸ Simulator: The "Dependency Hell"

Goal: Deploy your Python App to Production.
Constraint: Your App needs Python 3.9. The Server is old and has Python 3.6.

Waiting for deployment...
đŸ’ģ My Laptop (Dev)
OS: macOS
Python: v3.9
Libs: Pandas v1.0
🐍
MyApp.py
➔
â˜ī¸ Production Server
OS: Ubuntu Linux
Python: v3.6 (OLD)
Libs: Missing
Deployment Zone

📖 Core Vocabulary

📄 Dockerfile

The recipe. A text file containing instructions to build the image (e.g., "Install Python", "Copy files").

đŸ’ŋ Image

The blueprint (Cookie Cutter). It is a read-only template built from the Dockerfile. You store this in a Registry.

đŸ“Ļ Container

The actual cookie. It is a runnable instance of an Image. You can run 100 containers from 1 image.

⚓ What comes next? (Orchestration)

Kubernetes (K8s)

Docker is great for running one container. But what if you have 1,000? What if one crashes and needs restarting? What if you need to upgrade them without downtime?

That is what Kubernetes does. It manages (orchestrates) your fleet of containers.