// Free Docker Dev Tool

Docker Inspect Layers
Dockerfile Layer Inspector

Paste a Dockerfile to simulate docker inspect and docker history output. Analyze layer composition, cache invalidation points, and build structure — no Docker install needed.

Layer Analysis docker inspect sim Cache Detection JSON Output Free · No install
// Docker Layer Inspector
// Paste Dockerfile 0 lines
// Layer breakdown
Paste a Dockerfile and click
Inspect Layers
// Simulated docker image inspect output
// Run inspection first to see docker inspect JSON output
// Simulated docker history output
// Run inspection first to see docker history output

How docker inspect layers works

docker image inspect returns a JSON document containing full image metadata — including the RootFS.Layers array of SHA256 digests representing each filesystem layer. docker history shows the ordered list of instructions that built each layer, with its size and creation timestamp.

Not every Dockerfile instruction creates a filesystem layer. FROM, RUN, COPY, and ADD create new layers with filesystem changes. ENV, LABEL, EXPOSE, CMD, ENTRYPOINT, and WORKDIR create metadata-only layers that do not appear in the RootFS.Layers count — they are "zero-size" layers in docker history.

Why does docker inspect show fewer layers than docker history?
docker history shows all instructions including metadata-only steps. docker image inspect under RootFS.Layers only lists layers with actual filesystem changes. A Dockerfile with 10 instructions may produce only 4 layer digests if 6 of those instructions are ENV, EXPOSE, LABEL, or CMD.

How does layer caching work?
Docker caches each layer by its parent layer hash plus the instruction string. Cache is invalidated top-down — any change to a layer invalidates all subsequent layers. The most common mistake: COPY . . before RUN npm install means any source code change forces a full reinstall. Fix: copy only the dependency manifest first, run install, then copy source.

What does the CREATED BY field in docker history show?
The CREATED BY column in docker history shows the shell command that generated each layer. For RUN instructions, it shows the actual command. For COPY, it shows /bin/sh -c #(nop) COPY with file details. For base image layers, it shows the commands from the parent image's Dockerfile which you may not control.

FAQ
Use docker image inspect IMAGE for full JSON metadata including layer SHA256 digests. Use docker history IMAGE to see each layer's command and size. Use docker image inspect --format='{{json .RootFS.Layers}}' IMAGE to list only the layer digests. The dive tool provides an interactive explorer showing which files each layer adds or modifies.
docker inspect returns full image metadata as JSON including environment variables, exposed ports, entrypoint, architecture, and the RootFS.Layers digest array. docker history shows a human-readable table of each layer with its size and the instruction that created it. Inspect is for programmatic use; history is for debugging and optimization.
Chain RUN commands with && to combine multiple operations into a single layer: RUN apt-get update && apt-get install -y pkg && rm -rf /var/lib/apt/lists/*. Clean up in the same RUN instruction — cleanup in a later layer does not reduce image size because the files still exist in earlier layers. Use multi-stage builds to discard build-time layers entirely.
The RootFS.Layers field in docker image inspect is a JSON array of strings, each being a SHA256 digest: "sha256:abc123...". These digests correspond to the compressed layer tarballs stored in the Docker content store. The order is bottom-to-top: first element is the base layer, last is the most recent layer.
docker inspect layers docker image inspect docker history layers docker layer inspector inspect docker image layers docker image layers docker layer size dockerfile layer analyzer docker build layers docker rootfs layers