← Docker learning path
Docker · Module 2 of 10

Images and the Dockerfile

An image is a read-only template; a Dockerfile is the recipe that builds it.

📖 Key ideas

  1. An image is a read-only template; a container is a running copy of an image.
  2. A Dockerfile lists build steps from top to bottom.
  3. FROM picks the base image, for example node:20-alpine.
  4. COPY adds files, RUN executes commands at build time, CMD sets the start command.
  5. docker build -t myapp:1.0 . turns a Dockerfile into an image.
💡 Real-life example: An image is like a cake recipe printed in a book; each container is a cake baked from it.
ImageRead-only template for containers
DockerfileText file with build steps
FROMInstruction that chooses the base image
CMDDefault command when the container starts