As you may already know, a Docker container image is a lightweight, standalone, executable package of software that has everything required to run an application. That’s why container images are often used by developers for building and distributing applications. If you’re curious to know what is in a Docker image, this brief guide might help you. Today, we are going to learn to analyze and explore the contents of Docker images layer by layer using a tool named **“Dive”**. By analyzing a Docker image, we can discover possible duplicate files across the layers and remove them to reduce the size of the docker image. The Dive utility is not just a Docker Image analyzer, but also helps us to build one.
### Installing Dive
Get the latest version from the [**releases page**][1] and install it as shown below depending upon the distribution you use.
If you’re on **Debian** or **Ubuntu** , run the following commands to download and install it.
As you can see in the above screenshot, the layers of given docker image and its details, wasted space are shown in the left pane. On the right pane, the contents of each layer in the given Docker image. You can switch between the left and right pane using **Ctrl+SPACEBAR** key and **UP/DOWN** arrow keys to navigate through the directory tree.
The list of keyboard shortcuts to use “Dive”.
* **Ctrl+Spacebar** – Switch between left and right panes,
* **Spacebar** – Expand/Collapse directory tree,
* **Ctrl+A** – Show/hide added files,
* **Ctrl+R** – Show/hide removed files,
* **Ctrl+M** – Show/hide modified files,
* **Ctrl+U** – Show/hide unmodified files,
* **Ctrl+ L** – Show layer changes,
* **Ctrl+A** – Show layer changes,
* **Ctrl+/** – Filter files,
* **Ctrl+C** – Exit.
In the above example, I have used “sudo” permission, because my Docker images are stored in **/var/lib/docker/** directory. If you have them on your $HOME directory or anywhere not owned “root” user, you need not to use “sudo”.
You can also build a Docker image and do an immediate analysis with one command: ``
```
$ dive build -t <some-tag>
```
Dive tool is still in beta stage, so there will be bugs. If you came across any bugs, report them in the project’s github page.
And, that’s all for today. You know now how to explore and analyze the contents of Docker container image and how to build it using Dive tool. Hope this helps.