Based on Udemy Course: Docker & Kubernetes: The Practical Guide
Concepts
- A image is a sharable package that can be used in multiple containers
docker ps -a
show all containers (running & not running)docker run -it node
: expose the interactive session to the local machine- A container contains environment + code, so we need to copy the code to the container
- Images are read-only
- Image layer: docker will cache the build result, if nothing changes in the image, the docker will directly use cache. When one layer is changed, all subsequent layers will also be rebuilt.
1 | FROM node |
Optimize:
1 | FROM node |
^ this guarantees if we don’t need to rerun npm install again if anything is changed in app.