Back
1/5

What is Docker?

+10 XP on completion

#What is Docker?

After this lesson you'll know:

  • what makes containers different from VMs
  • what images and containers are
  • why Docker took over the world

Imagine: You're building an app. Runs locally. Your colleague clones the repo — doesn't run. "But it works on my machine!" — the classic.

Docker solves this by packing your app plus all dependencies into a standardized container. Identical everywhere.

#Container ≠ VM

This is the most common misconception. A VM virtualizes the hardware — a container virtualizes only the operating system.

VM:     [App] [Libs] [Guest OS] → Hypervisor → Host OS
Docker: [App] [Libs] → Docker Engine → Host OS

Containers share the host kernel. This makes them:

  • Lightweight — start in milliseconds, not minutes
  • Slim — megabytes instead of gigabytes
  • Efficient — dozens of containers on one server

#The mental model

Image     = Blueprint / recipe (read-only, reusable)
Container = Baked cake          (running, has state)
Registry  = Cookbook shelf      (hub.docker.com)

An image is the template. A container is a running instance of that image. You can start 10 containers from the same image — each lives its own life.

#Why Docker?

  • Reproducibility: Runs on my machine = runs on the server
  • Isolation: Each container has its own process environment
  • Portability: From development to production
  • Ecosystem: Thousands of ready-made images on Docker Hub

#✋ Try it out

  • docker run hello-world — your first container. When "Hello from Docker!" appears, everything works
  • docker run -d -p 8080:80 nginx — start an Nginx web server. Open http://localhost:8080
  • docker ps — see all running containers
  • docker stop $(docker ps -q) — stop all containers

#📌 Summary

  • Containers are lightweight, fast, and isolated — like a VM, but better
  • Images are blueprints, containers are running instances
  • Docker solves the 'but it works on my machine' problem forever
← → to navigate