Notes
Filed under · DevOps · 2026-08-12 · 4 min read
What I learned building with Docker
I treated my first Dockerfile like a tiny virtual machine: install everything, run it, ship it. It worked, but builds were slow and images were huge. The mental model that fixed it was simple — an image is a stack of layers, and each instruction either reuses a cached layer or invalidates everything after it.
dockerfileFROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
CMD ["npm", "run", "start"]Order your Dockerfile by what changes least. Dependencies before source.
Once I copied package manifests and ran the install before copying source, most rebuilds only re-ran the final COPY. Caching did the heavy lifting, and deploys stopped feeling like a coin flip.