Dive view the contents of docker images

Introduction

How to view the contents of docker images? “Dive” is a command-line tool for exploring and analyzing Docker images. It allows you to inspect the contents of a Docker image, view its layers, and understand the file structure and sizes within those layers.

This tool can be helpful for optimizing Docker images and gaining insights into their composition. Dive: A Simple App for Viewing the Contents of a Docker Image.

For MacOS, Dive can be installed with either Homebrew and on Windows, Dive can be installed with a downloaded installer file for the OS.

What You’ll Need

  • Dive: You’ll need to install the Dive tool on your system to use it.
  • Docker: Dive works with Docker images, so you should have Docker installed on your system to pull and work with Docker images. For example, install docker on Ubuntu here.

Installing Dive

To install Dive, you can use package managers like Homebrew (on macOS) or download the binary from the Dive GitHub repository.

Using Homebrew (on macOS)

brew install dive

Downloading the binary

You can visit the Dive GitHub repository (dive) and download the binary for your platform from the “Releases” section. You installing Dive on Ubuntu.

$ export DIVE_VERSION=$(curl -sL "https://api.github.com/repos/wagoodman/dive/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')
$ curl -OL https://github.com/wagoodman/dive/releases/download/v${DIVE_VERSION}/dive_${DIVE_VERSION}_linux_amd64.deb
$ sudo apt install ./dive_${DIVE_VERSION}_linux_amd64.deb

The result as the picture below

Dive view the contents of docker images

Using Dive

Once you have Dive installed, you can use it to view the contents of a Docker image as follows:

  1. Open your terminal or command prompt.
  2. Run the following command, replacing with the name or ID of the Docker image you want to inspect:
  3. Dive will launch a text-based interface that allows you to navigate through the layers of the Docker image. You can explore the file structure, check the sizes of individual layers, and gain insights into the image’s contents.

View the contents of docker images

To examine the latest Alpine Docker image

dive alpine:latest

You can define a different source using the source option

dive IMAGE --source SOURCE

SOURCE is the location of the repository.

The features of Dive

  • Layer Visualization: Dive provides a visual representation of a Docker image’s layers, showing how they are stacked on top of each other.
  • Layer Size Information: Dive displays the size of each individual layer in the Docker image.
  • File and Directory Listing: You can navigate through the contents of each layer and view the files and directories it contains.
  • Image Efficiency Analysis: Dive helps you identify inefficiencies in your Docker images.
  • Image Build Context Analysis: Dive can analyze the build context of a Docker image.
  • Image Diffing: Dive allows you to compare two Docker images and see the differences between them.

Conclusion

Dive is a powerful tool for image analysis and optimization, and it can help you gain insights into what’s inside a Docker image. It’s particularly useful for identifying large files or unnecessary dependencies that can be removed to create smaller and more efficient Docker images.

You can view the contents of docker images using Dive.

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created DevopsRoles.com site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.