https://github.com/IITC-College/express-js-app
Learning Goals
- Understand how Dockerfile instruction order affects build time
- See how small code changes can invalidate Docker cache
- Understand why image size stays the same while build performance changes
- Learn Dockerfile ordering best practices used in production environments
Part 1 — Understand Docker Cache Behavior
Tasks
- Inspect a previously built image using:
docker history <image-name>
- Review the layer order.
- Think about the following question:
- What happens to all layers after a changed layer?
Important Concepts
Docker cache is based on layer hashing.
If one layer changes:
- that layer is rebuilt
- every layer after it is rebuilt as well