Why Docker? Containers vs. Virtual Machines
"It works on my machine" is one of the oldest problems in software. Docker solves it by packaging an application together with everything it needs to run, code, runtime, libraries, system tools, into a single container that behaves the same everywhere.
Containers vs. virtual machines
| Virtual Machine | Container | |
|---|---|---|
| Includes | A full guest operating system | Just the app and its dependencies |
| Startup time | Minutes | Seconds |
| Size | Gigabytes | Often megabytes |
| Isolation | Full hardware-level virtualization | Shares the host OS kernel, isolated processes |
Containers are lighter because they don't boot a whole separate operating system, they share the host machine's kernel but keep everything else (filesystem, processes, network) isolated.
Images vs. containers
- An image is a read-only template, the blueprint (think: a class).
- A container is a running instance of an image (think: an object). You can start many containers from the same image.
NOTE
Docker Desktop (or Docker Engine on Linux) is the tool that builds images and runs containers. Install it before the next lesson.