You write a Dockerfile , run docker build , and get an image.
But what’s really happening under the hood? Docker isn’t just “building” your app — it’s assembling a stack of immutable filesystem layers .
Docker doesn’t build applications — it builds filesystem snapshots layer by layer .
Let’s break it down.
1. What is a Docker Image, Really?
A Docker image is not a single file .
It’s a stack of read-only layers .
Every instruction in your Dockerfile creates a new layer:
FROM → Base layer
RUN → Executes command and snapshots the result
COPY / ADD → Adds files into a new layer
ENV , WORKDIR , CMD → Metadata layers
These layers are:
Immutable
Content-addressed (using SHA256)
Reusable across images and builds
This design is what makes Docker fast and efficient.
2. How Docker Build Works (Step by Step)
When you run docker build .…