Lesson 8 / 26
Building an Image
docker build turns a Dockerfile into a runnable image.
docker build
-t tags the image with a name. The trailing . is the build context — the directory Docker can see and copy from.
docker build -t my-app:1.0 .
docker run -d my-app:1.0Layers & caching
Each instruction creates a layer. Docker caches layers and reuses them if nothing above them changed — that's why copying package.json and running npm install before copying the rest of the code speeds up rebuilds.