How to explore and optimize your Docker images with Dive

When you start to become interested in Docker, everything seems simple and light, at least on the surface. By the way, if you’re new to Docker, here is a guide on how to install Docker on Linux ex Ubuntu

But for a Docker image to be considered okay, it must be optimized, and it’s not necessarily instinctive, especially when you’re just starting out.

This is why I present to you a tool as magical as Fabien Olicard under Caprisun, which will not only allow you to understand the structure of your Docker images from top to bottom but also to optimize their size and free up this precious disk space that we all lack on our computers. This tool is Dive.

Imagine you are a developer or system administrator and regularly need to manipulate and manage Docker images. You know it’s crucial to optimize these images to reduce their size and thus improve their effectiveness, but you don’t know where to start. Dive is here to help you! With this tool, you will be able to easily analyze your Docker images, discover the modifications made within each layer, and optimize their size efficiently.

First, simply replace the command docker build with dive build to analyze the efficiency and wasted space of your Docker image.

dive <tag/id/digest of your image>

Dive supports multiple image sources and container engines (currently Docker and Podman). For installation, Dive is available for Ubuntu/Debian, RHEL/Centos, Arch Linux, Mac, and Windows.

To install it on macOS:

brew install dive

To install it on Linux (Ubuntu / Debian):

export DIVE_VERSION=$(curl -sL "" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')

curl -OL${DIVE_VERSION}/dive_${DIVE_VERSION}_linux_amd64.deb

sudo apt install ./dive_${DIVE_VERSION}_linux_amd64.deb

Integrating Dive into your CI (continuous integration) process is also possible using the environment variable CI=true. You can even configure rules in a file .dive-ci to automate certain checks and optimizations of your Docker images.

See also  How to Set Up Your Site with HCU and Take Advantage of Core Updates

Navigating Dive is a breeze, thanks to keyboard shortcuts. You will be able to explore the layers of your Docker images, filter files, manage layer-specific settings, and customize the user interface by creating a configuration file.

To learn more about Dive and its features, I invite you to consult the official GitHub repository here. Here, you’ll find all the information you need to master this fantastic tool, plus examples and tips for optimizing your Docker images like a pro.

5/5 - (1 vote)

Mohamed SAKHRI

I am Mohamed SAKHRI, the creator and editor-in-chief of Tech To Geek, where I've demonstrated my passion for technology through extensive blogging. My expertise spans various operating systems, including Windows, Linux, macOS, and Android, with a focus on providing practical and valuable guides. Additionally, I delve into WordPress-related subjects. You can find more about me on my Linkedin!, Twitter!, Reddit

Leave a Comment