Docker
“Works on my machine” — now guaranteed, everywhere.
▶ the lesson · narrated sketch video · tap for sound
the intro
Docker packages your application together with everything it needs — runtime, dependencies, config — into a container. The same container runs identically on your laptop, your teammate’s machine, and production. No more it-works-on-my-machine excuses.
the sample
the whole recipe, 4 lines
FROM node:20 COPY . . RUN npm ci CMD ["npm", "start"]
fun fact ✦
Containers share your OS kernel, so they are way lighter than full virtual machines.
the docs
the deep dive
the ideas behind the video — concepts, diagrams, a walkthrough and the traps to avoid
Every app is a needle in an environment-shaped haystack: the right Node version, the right libraries, the right OS quirks. Containers let you stop describing the haystack and just ship it, sealed, with the needle inside. And because containers share the host kernel instead of virtualizing hardware, they cost seconds and megabytes, not minutes and gigabytes.
ship the environment, not just the code
key terms
image
A read-only template: your app plus its runtime, frozen at build time.
node:20-alpine, myapp:1.4container
A running instance of an image with a thin writable layer on top. Delete it and that layer is gone.
docker run -p 3000:3000 myapplayer
Each Dockerfile instruction becomes a cached layer. Change code and only the layers after the change rebuild.
the npm ci layer stays cachedvolume
A folder Docker manages outside the container, so data outlives the container.
-v pgdata:/var/lib/postgresqlhow it works
- 1Write the Dockerfile
A dozen lines describing the world: base image, copy code, install, start command. This is the recipe.
- 2Build the image
docker build -t myapp . bakes the recipe into cached layers. Change code and only the changed layers rebuild.
- 3Run a container
docker run -p 3000:3000 myapp turns the image into a live process. Run it twice and you have two identical copies.
- 4Ship it anywhere
docker push puts the exact bytes in a registry. Any machine with Docker pulls and runs the identical thing.
the code, explained
the recipe that becomes the image
side by side
container
- shares the host kernel
- starts in milliseconds
- images measured in MB
- isolation via namespaces
- cheap: no guest OS to run
virtual machine
- ships an entire guest OS
- boots in tens of seconds
- images measured in GB
- strongest isolation boundary
- heavier on RAM and disk
Run docker rm on a container and everything the app wrote inside it vanishes with it. Databases, uploads, sessions — anything you would cry about — belongs in a volume. The container itself should stay disposable.
quick answers
Is Docker a virtual machine?
No. A VM virtualizes hardware and boots a whole operating system; a container is just ordinary processes isolated by namespaces on the shared kernel. That is why they start instantly.
Why did my container's data disappear?
The writable layer dies with the container. Anything that must survive lives in a volume, which down and rm cannot touch.
Alpine or a full base image?
Alpine images run around 130MB where fat ones exceed a gigabyte. One catch: Alpine uses musl libc, so native modules can behave differently — test before you commit.
quick hits about Docker
short answers · interviews, tips, trivia & hidden gems
Image vs container?watch ↗
Why do containers isolate?watch ↗
Dockerfile lines decodedwatch ↗
Build, tag, push, pullwatch ↗
The five run flags you use dailywatch ↗
Code changes without rebuilds?watch ↗
1GB images → 80MBwatch ↗
Copy files in and out of containerswatch ↗
Ten times faster buildswatch ↗