How Container Images Work: Container Layer Explorer (.NET)
Most developers use container images every day without a clear picture of how one is built. When I teach containers, giving students that mental model is often a challenge. To help with this, I built Container Layer Explorer, so I could show on screen how an image is built, layer by layer. I have now released it as a free, open-source tool you can try with your own images.
It is a small local web tool, written in .NET, that opens an image from your local Docker engine and shows each layer and the files it adds, changes or deletes. It follows your builds live, so you can edit a Dockerfile, rebuild and watch what changes.

The Matrix view has one row per path and one column per layer.
In the screenshot above we can see that:
Hello1.txtwas added in layer 3 and modified in layer 4.Hello2.txtwas also added in layer 3, but later deleted in layer 5.
Here is what you will learn in this post:
- What a layer actually holds
- How added, changed and deleted files are stored in an image
- Why a deleted secret is still in the image, and why deleting a big file does not shrink it
- What anyone with a copy of your image can read from it
Contents:
- How It Works
- Getting Started with Container Layer Explorer
- Example 1: A Layer Holds Only What Changed
- Example 2: Add, Modify and Delete a File
- Example 3: A Deleted Secret Is Still in the Image
- Example 4: Deleting a Big File Does Not Shrink the Image
- What an Image Reveals
- Frequently Asked Questions
- I Want Your Feedback!
- Learn Containers and Kubernetes in One Day
How It Works
Container Layer Explorer runs on your own computer, next to Docker Desktop, and works only with the images in your local Docker engine. It never talks to a registry, so to look at an image from Docker Hub, pull it first.

Everything runs on your computer. The registry is only involved when you pull.
When you open an image, the tool exports it through the Docker Engine API (the same export as docker save) into a temporary folder. It reads the layers, the config and the manifest from that copy and shows them in your browser. It also listens to Docker’s image events, so the page updates by itself when you build, tag or remove an image.
Getting Started with Container Layer Explorer
There are two ways to try it: open an image you already have in Docker, or build the small sample from the repository, which creates an image called busybox-demo. Both start the same way, with the steps below. The short version is in the README’s Quick start.
What You Need
- Windows with Docker Desktop, running, in Linux containers mode (the default).
- The .NET 10 SDK.
- Git, to get the source code.
Using Linux, macOS or another container engine? See the FAQ.
There are no binary downloads. You build and run the tool from source.
Run the Tool
Start Docker Desktop, then clone the repository and run the tool:
git clone https://github.com/tndata/ContainerLayerExplorer.git
cd ContainerLayerExplorer
dotnet run --project src/ContainerLayerExplorer
When the terminal shows Now listening on: http://localhost:5000, open http://localhost:5000 in your browser. Leave the terminal running; Ctrl+C stops the tool. If the page does not open or cannot reach Docker, see Troubleshooting in the README.
The start page lists the tagged images in Docker Desktop, and the list updates by itself when you build, tag or remove an image.

The start page. Choose Explore next to an image to open it.
In the screenshot above, the tool has found three images in Docker Desktop, including the busybox-demo sample. The Docker panel at the top shows that it is connected to the Docker engine.
The tool only reads from Docker. It never pushes, pulls, deletes or changes an image, and it never starts a container.
Exploring an Image
Pick an image and choose Explore. The page has two views, with a switch at the top.
The Matrix view opens first. Each column is a layer, and each row is a path. A cell says what that layer did to that path:
- A means the layer added the file or folder
- M means the layer wrote it again (the whole file is stored again, and the content is not compared)
- D means the layer deleted it (it is only hidden by a whiteout marker)
The Result column shows the files that exist at the end of the build, which is what a container sees when it starts. A tick means the file is there.
The Stack view shows the same image the way it is often drawn on slides, with the first build step at the bottom and the last one on top. Each box is a layer, with its build command and two sizes: stored (compressed) and of files (uncompressed). Click a layer to see its details on the right.

The panel on the right lists what anyone with a copy of the image can read from it.
With the tool up and running, let’s put it to work. In the four examples below, we build small images and use the tool to see what each layer holds, from an empty image to a deleted secret you can still read.
Example 1: A Layer Holds Only What Changed
Let’s start with the simplest possible image, built on scratch. scratch is a special, reserved name in Docker: it is not an image you can pull, but an empty starting point with no files at all. That makes it a good place to see what a single layer holds.
In a new, empty folder, create a Dockerfile with a single line:
FROM scratch
Build it:
docker build -t scratch-demo .
Open the scratch-demo image in the tool. It shows the message “This image is empty (it has no layers).”
Now create a file one.txt with any text in it, and copy it into the image:
FROM scratch
COPY one.txt /
Rebuild with the same command and keep the page open. The page updates by itself and shows one layer column with one file in it, added (A) in layer 1.
Create a second file, two.txt, and add one more line:
FROM scratch
COPY one.txt /
COPY two.txt /
Rebuild again, and the Matrix now shows two layer columns:

The NEW badge marks the layer that appeared after the rebuild.
In the screenshot above, layer 2 holds only two.txt. The cell for one.txt in layer 2 is empty, because that build step did not touch it, and the Result column has a tick for both files. That means both files are in the final image.
The lesson: a layer is a diff. It holds only the files its build step added or changed, each one stored whole, and a marker for each file it deleted. It is not a full copy of the file system. The image you run is all the layers stacked on top of each other and merged into one file system, the idea behind a union file system. The Result column is the outcome.

The docker build command turns the steps in a Dockerfile into a container image.
Example 2: Add, Modify and Delete a File
The Container Layer Explorer repository has a small sample, samples/busybox-basics, that shows all three kinds of change. It is built on BusyBox.
BusyBox packs many common Unix tools, such as sh, ls, cat and wget, into one small program, so the whole image is only a few megabytes. That makes it a good base image when you want to:
- Experiment with Dockerfiles and layers, as we do here
- Run a quick test or debug container, for example to check network access from inside a cluster
- Run a small helper task, such as a Kubernetes init container that waits for a service to start
It has no package manager, so it is not a good base for most applications.
I use the exact tag busybox:1.38.0-glibc instead of busybox:latest. A tag like latest moves to each new release, and then the base layer and its files change too. With a pinned version, your layers match my screenshots. It is a good habit in your own Dockerfiles as well, so a new base image release does not change your image without you noticing.
The Dockerfile is:
FROM busybox:1.38.0-glibc
# Layer 2: a working directory. Everything below goes into /src.
WORKDIR /src
# Layer 3: two new files (A = added).
COPY Hello1.txt Hello2.txt ./
# Layer 4: Hello3.txt is copied over Hello1.txt (M = changed). The whole file is stored again.
COPY Hello3.txt Hello1.txt
# Layer 5: Hello2.txt is deleted (D = deleted). It is only hidden: its data is still stored in layer 3.
RUN rm Hello2.txt
It comes with three text files:
Hello1.txt: This is Hello1!
Hello2.txt: This is Hello2!
Hello3.txt: This is Hello3!
From the root of the cloned repository, build it:
docker build -t busybox-demo samples/busybox-basics
Open the busybox-demo image in the tool. The Matrix shows five layer columns, with BusyBox itself in layer 1. Expand the src folder, or type src in the filter box, and look at the two files:
Hello1.txtis added in layer 3 and modified in layer 4. Click the M cell: layer 4 stores the whole new file, and the old version is still in layer 3.Hello2.txtis added in layer 3 and deleted in layer 5. Click the D cell: layer 5 stores only a whiteout marker,.wh.Hello2.txt. The data is still in layer 3, and Show it shows you the content.
A whiteout marker is an empty file named after the deleted file, with a .wh. prefix. A layer cannot remove files from the layers below it, so it adds this marker instead, and the marker hides the file when the layers are stacked. The OCI image specification defines how this works.
Your Matrix should look like the screenshot at the top of this post.
The lesson: an image never edits or removes anything in a lower layer. A change is a new copy of the whole file in a higher layer, and a delete is a marker that hides the file. The older data stays where it was.
Example 3: A Deleted Secret Is Still in the Image
This is the same mechanism with a more serious consequence. In a new, empty folder, create a file secret.txt with a made-up secret in it, for example API_KEY=not-a-real-key-12345, and this Dockerfile:
FROM busybox:1.38.0-glibc
# Copy the secret file into the image.
COPY secret.txt /secret.txt
# Delete it again.
RUN rm /secret.txt
docker build -t secret-demo .
If you run a container from this image, /secret.txt is not there. Open the secret-demo image in the tool. The row for secret.txt has an A in layer 2 and a D in layer 3, and no tick in the Result column. Click the D cell. The panel says the data is still stored in layer 2. Click Show it, and the tool jumps to layer 2 and shows your secret.

The file is gone for the container, but not for the image.
Anyone who has a copy of the image can do the same, with or without this tool. Exporting the image with docker save and unpacking its layers is enough.
The lesson: deleting a secret in a later step hides it from the running container, but not from the image. A secret that was ever copied into a layer must be treated as leaked, and rotated. The fix is to never put it in a layer in the first place. If the build needs the secret, use Docker’s build secrets (RUN --mount=type=secret). A multi-stage build also keeps the secret out of the final image, but it is still in the earlier stage’s layers in your build cache, so build secrets are the safer choice. If the application needs it, give it to the container when it starts.
Example 4: Deleting a Big File Does Not Shrink the Image
The same mechanism also affects size. In a new, empty folder, create this Dockerfile, where one step creates a file of 50 MB and a later step deletes it:
FROM busybox:1.38.0-glibc
# Create /big.bin with 50 MB of random data: dd reads 50 blocks of 1 MB from /dev/urandom.
RUN dd if=/dev/urandom of=/big.bin bs=1M count=50
# Delete /big.bin again.
RUN rm /big.bin
docker build -t big-bad .
I use random data on purpose. A file full of zeros would compress to almost nothing in the stored size and hide the point.
Open the big-bad image in the tool and switch to the Stack view. Layer 2 holds about 50 MB of files, and layer 3, which deletes the file, holds almost nothing. Click layer 2 and look at the row Hidden by later layers: the 50 MB are still stored, but no container can see them. Above the stack, the image’s size of files and stored size both include the deleted file.

The image is 54.2 MB, even though no container can see the 50 MB file.
How Do We Get Rid of Those 50 MB?
The goal is that the temporary file never ends up in any layer at all. A layer is a snapshot of what its build step changed, taken when the step has finished. If the file is created and deleted within the same step, it is already gone when the snapshot is taken.
Replace the Dockerfile with this one, where the file is created and deleted in the same RUN. To keep a visible result, the step first writes the file size to a small text file:
FROM busybox:1.38.0-glibc
# One step: create the 50 MB file, write its size in bytes to /size.txt, then delete the file.
RUN dd if=/dev/urandom of=/big.bin bs=1M count=50 && \
wc -c /big.bin > /size.txt && \
rm /big.bin
docker build -t big-fixed .
Open the big-fixed image in the tool, in the Stack view, and compare it with big-bad:
- The image is now 4.2 MB of files (2.1 MB stored), down from 54.2 MB (52.1 MB stored). The 50 MB file is gone.
- There are two layers instead of three, and the new layer holds only
size.txt, 18 bytes.
The file was created and used during the build, but none of its 50 MB ended up in the final image.

The image is back to the size of its BusyBox base.
The lesson: a layer can only add to the size of an image. Temporary files, such as downloads, unpacked archives and build tools, must be created and removed in the same RUN, so they never end up in a layer. The alternative is a multi-stage build: do the work in an earlier stage, and copy only what you need into the final image.
What an Image Reveals
An image carries more than its files. Each layer remembers the build step that created it, so anyone with a copy of the image can read how it was built, step by step:

Anything typed on a RUN line can be read here, so keep passwords out of it.
Click the box around the stack and you get What this image reveals: the other facts anyone can read from the image’s config and manifest. Hover over a row, or click the ? button, to see why it matters.
Instructions such as ENV, LABEL and CMD add no files, so they create no layer. Their values are stored in the image config instead, and the tool lists them here. In the Stack, they are the thin 0 B rows.
From a security point of view, a few of these rows are worth a look in your own images:
- Build steps. The build history is written by the tool that built the image. A normal Docker build stores each
RUNcommand as it was run. Anything you type on aRUNline, such as a password, can be read from the image, and a build argument used by aRUNcan show up too. The Dockerfile itself is not in the image config. - Environment. Every
ENVvalue is stored in the image config and travels with every copy of the image, including a value meant to be secret. - Labels and build times. Labels can name the source repository and the git commit. Build times show when the image was made, and a base image is often older than the steps on top of it.
The layer details add more. Click a layer in the stack and you see its biggest files, the data that later layers hide (Examples 3 and 4), and permission facts such as setuid programs and world-writable folders. These come from the layer’s file list, not from the content of the files.
Pull an image you are curious about and open it in the tool.
Frequently Asked Questions
What is the difference between Docker, container and OCI images?
A container image is the general term: an application and the file system it needs, packed as a stack of layers, plus the settings for starting it. Docker images and OCI images are two closely related formats for it. The OCI Image Specification is the open standard from the Open Container Initiative, and Docker donated its own format to the initiative as the starting point. The tool opens both, as long as the image is in your local container engine. Images with zstd-compressed layers are not supported yet.
Can I look at an image from Docker Hub or another registry?
Yes, once you have pulled it into Docker Desktop, for example with docker pull busybox:1.38.0-glibc.
Does it work on Linux, macOS or with other container engines?
I have only tested it on Windows with Docker Desktop. Podman and Rancher Desktop (with its dockerd engine) offer a Docker-compatible API, so they may work, but I have not tried them. If you try, tell me how it went in a GitHub issue.
I Want Your Feedback!
The code is open source under the MIT license, at github.com/tndata/ContainerLayerExplorer. If you try it and find a bug, have a feature request, or want to share your experience, please create an issue on GitHub. Contributions are welcome.
Learn Containers and Kubernetes in One Day
I use Container Layer Explorer in my one-day, hands-on course Introduction to Containers and Kubernetes. We build images, look at what goes into them, and then deploy them to Kubernetes, step by step. By the end of the day, each participant has a containerized sample application running in their own Kubernetes cluster in the cloud, scaled out to several instances.