Learn to Code
All tracks
Learn to Code

Free lessons from scratch to pro — every language, databases and DevOps.

AboutContactPrivacy PolicyTerms of Use

Your progress is saved in this browser. © 2026 Learn to Code

DK
Docker
0/10 completed
Beginner
Why containers?Install Docker and run your first containerImages vs containers
Intermediate
Writing a DockerfileVolumes and persistent dataNetworking and ports
Advanced
Docker ComposeMulti-stage builds and small images
Pro
Security and production best practicesRegistries and CI/CD
Tracks / Docker / Beginner

Why containers?

"It works on my machine!" Every developer has said it. Your app runs on your laptop, then breaks on a teammate's laptop or on the server, because they have a different Node version, a missing library or another operating system.

Docker solves this by packaging your app together with everything it needs (runtime, libraries, system tools and config) into a container. A container runs the same way everywhere: your laptop, a CI server, or a cloud machine.

Containers vs virtual machines

Virtual machine Container
Includes A full guest operating system Just the app + its dependencies
Size Gigabytes Megabytes
Start time Minutes Seconds or less
Isolation Very strong (separate kernel) Strong (shared host kernel)
Density A few per server Dozens to hundreds per server

A VM pretends to be a whole computer. A container is an isolated process on the host. It uses Linux kernel features (namespaces for isolation and cgroups for resource limits) so it only thinks it's alone.

 Virtual machines                     Containers
┌──────┐┌──────┐┌──────┐       ┌──────┐┌──────┐┌──────┐
│ App  ││ App  ││ App  │       │ App  ││ App  ││ App  │
│ Libs ││ Libs ││ Libs │       │ Libs ││ Libs ││ Libs │
│GuestOS│GuestOS│GuestOS│       └──────┘└──────┘└──────┘
└──────┘└──────┘└──────┘       ┌──────────────────────┐
┌──────────────────────┐       │    Docker Engine     │
│      Hypervisor      │       ├──────────────────────┤
├──────────────────────┤       │    Host OS (kernel)  │
│       Host OS        │       ├──────────────────────┤
├──────────────────────┤       │      Hardware        │
│       Hardware       │       └──────────────────────┘
└──────────────────────┘

Key vocabulary

  • Image: a read-only template: your app plus its environment, frozen. Think of it as a class, or a recipe.
  • Container: a running instance of an image. Think of it as an object, or the cooked meal. You can run many containers from one image.
  • Dockerfile: a text file with instructions to build an image.
  • Registry: a place to store and share images. Docker Hub is the public one; companies use AWS ECR, GitHub Container Registry and others.
  • Docker Engine: the background service (daemon) that builds and runs containers.

Why companies use Docker

  • Consistency: dev, test and production run the identical image.
  • Fast onboarding: a new developer runs one command instead of following a 3-page setup guide.
  • Isolation: run Postgres 14 and Postgres 16 side by side without conflict.
  • Microservices: each service ships as its own container.
  • Foundation for Kubernetes: container orchestration starts here.

How this track works

Docker runs on your computer, not in the browser. Each lesson gives you commands to copy (use the Copy button) and run in your own terminal. By the end, you'll containerize a real web app with a database, shrink it for production, and push it through a CI/CD pipeline.

✎ Check your understanding

1.What's the main difference between a container and a VM?

2.An image is to a container as…