Foundations: web, servers, containersLesson 10 of 13
How an Image Is Built and Run
Follow what an image, the source of a container, is made of, what name it carries, and where it is stored before it becomes a container. Running the build automatically in a pipeline is covered in How a Pipeline Runs, and how a node's kubelet and runtime pull the image and start a Pod is covered in How a Pod Starts. Here we focus on the image itself.
Imageweb:1.4.2
Image locationBuild machine
Vuln scan—
Running containers—
RequestResponse / reportAppears in a later step
What you will learn
- Each Dockerfile line becomes one layer
- How to read an image name: registry, project, name, tag
- Why the latest tag is risky, and what a digest is
- "Not scanned" is not the same as "0 vulnerabilities"
- Deleting a container deletes the data written inside it
Easily confused pairs
| Pair | Difference |
|---|---|
| Image / container | An image is the read-only source. A container is that image running (a process) |
| RUN / CMD | RUN runs once at build time. CMD runs every time a container starts |
| Tag / digest | A tag is a label that can move. A digest is a fixed unique value computed from the content |
| latest / 1.4.3 | latest does not automatically point to the newest. Production uses tags that pin a version |
| Not scanned / 0 vulnerabilities | No result because there is no scanner is not the same as scanned and found none |
| EXPOSE / actual exposure | EXPOSE only documents a port. It does not make the port reachable from outside |
Try it yourself
docker image history <image> # Layers and the line that made each
docker image inspect <image> --format '{{.RepoDigests}}' # Digest: the content fingerprint
docker pull <image> # Layers already present are skipped
trivy image <image> # Vulnerabilities by severity (if Trivy is installed)
kubectl get pod <pod> -o jsonpath='{.status.containerStatuses[*].imageID}' # Digest the node actually pulled
Check yourself
Further reading: Images (Kubernetes docs) · Docker Build · Harbor · How a Pod Starts