Docker image history and layers
Quick answer
Images combine filesystem layer changes and configuration. docker image history exposes recorded build history, which helps explain how an image was assembled.
How it works
Think of one layer adding a file and a later layer hiding it. The final view no longer shows the file, but older layer content may still contain it. History records need not map one-to-one to filesystem layers: metadata-only instructions can add history without adding filesystem data. Build systems can also omit or alter historical detail.
Lab prerequisites
Use only a disposable approved Linux-container Docker context. Confirm the active context with docker context show before any mutation. The instructor must preload and review busybox:1.37 for the target platform and record its digest. The tag is a fixture convention inherited from earlier chapters, not a verified immutable version. Commands are static examples, not executed by ByteMind. Before any engine request, confirm the effective approved daemon endpoint, including DOCKER_HOST, DOCKER_CONTEXT and CLI overrides; do this privately in each terminal. Confirm the local tag still resolves to the approved image identity and platform. If any check fails, use the paper exercise instead.
Command example
docker image history --format '{{.Size}}' busybox:1.37docker image inspect --format '{{json .RootFS.Layers}}' busybox:1.37The first command lists recorded history entry sizes. The second lists filesystem layer identifiers (uncompressed diff IDs) if supplied by the image store. The counts may differ. Values are intentionally not fixed here; record observations from the approved fixture. History sizes are formatted display values, not the compressed sizes transferred from a registry. A zero-byte history record can describe metadata only.
Common mistakes
Never put credentials in a build layer and assume deleting them in a later layer is sufficient. A history listing is also not a complete list of files or a vulnerability scan.
Manual practice
Compare the number of history entries with the number of filesystem layers; explain why they need not match. Use only approved public image metadata.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Docker image history and layers — Knowledge check
Apply the concepts from this lesson.
Must every history entry add filesystem bytes?
What can happen to a file removed by a later layer?
Does history prove an image is safe?