← Docker learning pathDocker · 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
- An image is a read-only template; a container is a running copy of an image.
- A Dockerfile lists build steps from top to bottom.
- FROM picks the base image, for example node:20-alpine.
- COPY adds files, RUN executes commands at build time, CMD sets the start command.
- 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