Chapter 6: Docker Images and Containers
6.1 Why containers — box the app runtime
"Works on my machine" fails when the server has another Python version, missing library, or different config. A container packages the app with its runtime dependencies so the same box runs on a laptop and on a server.
Virtual machines give each guest a full virtual hardware + guest OS (heavy). Containers share the host OS kernel and isolate processes with a lightweight filesystem layer (the image). You already launch VMs in the AWS Cloud course (EC2). Here we do not re-teach hypervisors, VPC or EC2 launch — we use Docker to box the app.
Why it matters for an Instagram-style badge API : every environment should run the same badge API — same base image, same commands — whether a trainee laptop or a small cloud VM.
| Virtual machine (EC2-style guest) | Container |
|---|---|
| Full guest OS | Shares host kernel |
| Minutes to boot (often) | Seconds to start |
| Great for whole servers | Great for one app/process shape |
| Learn deeply in AWS course | Core of this chapter |
Ravindra Bagale's Tip
Interview madhe "container = halka VM" ulta sangu naka. Share kernel, isolate process + filesystem — he more accurate. Lakshat theva!