docker history Command Reference
Show the layer history of an image.
docker history lists the layers that make up an image, each with the instruction that created it and the size it added. In CI it helps diagnose why an image is large or why a layer keeps cache-missing on every build.
Common flags
--no-trunc- show full output without truncating the command column-H, --human- print sizes in human-readable units (default true)-q, --quiet- show only layer IDs--format- Go template output for scripting
Example
shell
docker history --no-trunc myorg/app:${{ github.sha }}
docker history --format "{{.Size}}\t{{.CreatedBy}}" myorg/app:latestIn CI
When an image is unexpectedly large, docker history shows which instruction added the bulk so you can reorder, combine, or move that work to an earlier multi-stage stage. It also reveals a layer whose command changes every build and therefore never caches.
Key takeaways
- history attributes size to each layer-creating instruction.
- --no-trunc reveals the full command behind a fat or cache-busting layer.
- Use it to guide multi-stage refactors that shrink the final image.
Related guides
docker images Command ReferenceReference for docker images in CI: list local images with --filter, --format, and -q to inspect or script ove…
docker build Command ReferenceReference for docker build in CI: tag, file, build-arg, target, platform, no-cache, and pull flags for buildi…
docker inspect Command ReferenceReference for docker inspect in CI: print low-level JSON for containers, images, volumes, and networks, and e…