🐳 Lesson 1: Introduction to Docker
What Docker actually is, why it changed software forever, and the mental model that makes everything else in this course click.
🎯 Learning Objectives
By the end of this lesson, you will be able to:
- Explain what a container is, in plain language
- Describe the difference between containers and virtual machines
- Articulate the "works on my machine" problem and how Docker solves it
- Recognize where Docker fits across development, testing, and production
Estimated Time: 30–40 minutes
Prerequisite: None — this is your starting point.
In This Lesson
The Problem Docker Solves
Picture a developer finishing a feature. It runs perfectly on their laptop. They hand it off — and it breaks in testing. It breaks again in production. It breaks on a teammate's machine. The dreaded refrain follows: "but it works on my machine!"
Why does this happen? Software doesn't run in a vacuum. It depends on a specific version of a language runtime, particular libraries, environment variables, operating-system packages, and configuration. When any one of those differs between two machines, behavior differs. Reproducing an environment by hand is slow and error-prone.
Docker's core idea: package your application together with everything it needs to run — code, runtime, libraries, and configuration — into a single, standardized unit called a container. That container then runs the same way on any machine with a container runtime. The environment travels with the app.
📖 Definition
Container: a lightweight, isolated, runnable package that bundles an application with its dependencies, so it runs consistently across different computing environments.
Containers vs Virtual Machines
People often confuse containers with virtual machines (VMs). Both isolate workloads, but they do it at very different levels. An analogy: a virtual machine is a separate house — its own foundation, plumbing, and walls. A container is an apartment in a shared building — it has its own private space, but shares the building's foundation and utilities.
Because containers skip the per-app guest OS, they are dramatically lighter:
| Aspect | Virtual Machine | Container |
|---|---|---|
| Isolation level | Full OS, virtualized hardware | Process-level, shared kernel |
| Size | Gigabytes | Megabytes |
| Startup time | Seconds to minutes | Milliseconds to seconds |
| Overhead per app | A whole guest OS | Just the app + its libs |
| Density (per host) | A handful | Dozens to hundreds |
⚠️ Note: Containers and VMs are not enemies — they're complementary. In the cloud you'll often run many containers inside a VM, combining the strong isolation of VMs with the efficiency of containers.
The Container Mental Model
The shipping-container analogy
Before standardized shipping containers, moving goods was chaos: every item needed custom handling, different trucks, special loading. The steel shipping container changed the world by standardizing the box — any container fits any ship, crane, truck, or train, regardless of what's inside.
Docker does exactly this for software. Your app might be Python, Node, Java, or Go — Docker wraps it in a standard container that any Docker host can run, without caring what's inside.
What "runs anywhere" really means
Think of a coffee-shop franchise. Every location — New York, Tokyo, London — needs the exact same recipe, equipment settings, and process so the coffee tastes identical everywhere. A Docker image is like a "coffee shop in a box": open it anywhere and you get the same result.
So a container is best pictured as a lightweight, portable, self-sufficient box. It is:
- Lightweight — a backpack, not a moving truck
- Portable — like a USB drive that works on any computer
- Self-sufficient — a meal kit with every ingredient included
- Isolated — soundproof rooms in a recording studio
- Reproducible — a recipe that always yields the same dish
✅ Image vs Container
An image is the blueprint (the recipe); a container is a running instance of that image (the meal you cooked). One image can start many containers. We'll go deep on both in Lesson 2.
Where Docker Fits
The same image flows through your entire pipeline — you build it once and run it everywhere, unchanged.
The benefits land differently for different roles:
| Developers | Operations | Business |
|---|---|---|
| No more dependency hell | Simple, repeatable deployments | Faster time to market |
| Consistent environments | Better resource utilization | Lower infrastructure costs |
| Easy collaboration & onboarding | Effortless horizontal scaling | Higher reliability |
Try It Yourself
Enough theory — let's see Docker prove itself. If you've installed Docker (see the setup steps), run:
docker run hello-world
Docker can't find that image locally, so it pulls it from Docker Hub, creates a container from it, and runs it. You'll see something like:
Output:
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
Digest: sha256:...
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
In that single command, Docker did four things: the client contacted the daemon, the daemon pulled the image, created a container from it, and streamed its output back to you. That's the whole workflow in miniature — you'll unpack each piece in Lesson 2.
🏋️ Exercise 1: Prove portability to yourself
Objective: Experience "pull once, run anywhere."
Instructions:
- Run
docker run hello-worldand read the output. - Run it a second time. Notice it no longer downloads — the image is cached locally.
- Run
docker imagesand findhello-worldin the list. Note how tiny it is (~20 kB).
💡 Hint
If you get a permission error on Linux, either add your user to the docker group or prefix commands with sudo.
✅ What you should observe
The first run downloads the image; the second run starts instantly from cache. docker images lists hello-world with a size in kilobytes — a fraction of any virtual machine. That tiny, cached, instantly-runnable unit is the container advantage.
Quick Quiz
Question 1: What is the main difference between a container and a virtual machine?
Question 2: What problem is Docker most famous for solving?
Question 3: What is the relationship between an image and a container?
Summary
🎉 Key Takeaways
- Containers package an app with everything it needs, so it runs the same everywhere — ending "works on my machine."
- Containers share the host kernel, making them far lighter and faster to start than virtual machines.
- An image is the blueprint; a container is a running instance of that image.
- The same image flows through dev, test, and production unchanged — build once, run anywhere.
📚 Additional Resources
- Docker overview — the official introduction
- What is a container? — Docker's own explainer
🚀 What's Next?
You understand what Docker is and why it matters. Next, we'll open the hood and see how it works — the engine, the client/daemon split, and how images, containers, networks, and volumes fit together.
🎉 Lesson 1 complete!
You've built the mental model everything else rests on. Onward!