dive
Explore and analyze Docker image layers
TLDR
Analyze a Docker image
Build an image and start analyzing it
SYNOPSIS
dive <image_name_or_id>
dive <path/to/tarball>
PARAMETERS
-h, --help
Show dive's usage and options.
-v, --version
Display the version information for dive.
-j, --json
Output image analysis in JSON format to stdout, instead of the interactive UI. Useful for scripting.
-o, --output FILE
When used with --json, specifies a file to write the JSON output to.
--ci
Run in CI mode, which disables the interactive UI and is intended for automated environments. It will output to console or specified file.
--source SOURCE
Specify the image source (e.g., 'docker', 'podman', 'docker-archive', 'oci-archive', 'tar'). Defaults to 'docker'.
--sort SIZE_DESC
Sort layers by size in descending order (true/false). Defaults to 'false'.
DESCRIPTION
dive is an open-source command-line tool that allows users to explore the contents of Docker (or OCI) images, layer by layer, directly within the terminal. It provides an interactive TUI (Terminal User Interface) that visualizes the filesystem changes and history of each image layer.
The primary goal of dive is to help developers understand how images are constructed, identify wasted space, duplicate files, and inefficiencies in their Dockerfiles. By inspecting the differences between layers, users can detect opportunities for image size optimization, improve build performance, and ensure their container images are as lean and secure as possible. It supports both local images and remote images (pulled by Docker/Podman).
CAVEATS
dive requires a running Docker or Podman daemon to pull and analyze images. While powerful, analyzing very large images or images with a high number of layers can sometimes be slow. The interactive terminal UI may have compatibility issues with some older or non-standard terminal emulators. It's a tool for analysis, not for building or modifying images.
INTERACTIVE UI
The dive interactive interface is typically split into two panes:
Left Pane: Layers View
This pane displays a list of image layers, showing their size, the command that created them, and their efficiency. Users can navigate through these layers to see how the image's filesystem evolves.
Right Pane: Filesystem Changes View
This pane shows the filesystem changes (added, removed, or modified files) specific to the currently selected layer. It allows users to browse the directory structure, identify individual files, and understand their contribution to the layer's size. It also highlights 'wasted' space and duplicate files.
WASTED SPACE ANALYSIS
One of dive's key features is its ability to automatically detect and highlight 'wasted space' within an image. This includes files that are added in one layer but later removed or overwritten in subsequent layers, contributing to the overall image size without providing final value. By identifying such inefficiencies, dive helps users optimize their Dockerfiles to produce smaller, more efficient container images.
HISTORY
dive was created by Alex Goodman and first released around 2018. It is written in Go and quickly gained popularity within the container community due to its intuitive and powerful interactive interface for image analysis. Its development is community-driven and actively maintained on GitHub, continually adding features and improving performance to keep pace with evolving container technologies.