LinuxCommandLibrary

dive

Explore and analyze Docker image layers

TLDR

Analyze a Docker image

$ dive [your_image_tag]
copy

Build an image and start analyzing it
$ dive build -t [some_tag]
copy

SYNOPSIS

dive [OPTIONS] <IMAGE>

PARAMETERS

-c, --cmd <CMD>
    User-defined command to run inside layers (default: sh)

--config <FILE>
    Path to custom configuration file

--help-short
    Print short help message

--layers-cache-size <SIZE>
    Max layers to cache (default: 3)

-h, --help
    Print full help information

--no-open
    Disable automatic browser opening for CI use

-V, --version
    Print version information

DESCRIPTION

dive is a powerful open-source CLI tool designed for exploring and analyzing Docker images layer by layer. It provides an interactive terminal user interface (TUI) that visualizes each layer's contents, highlighting added, deleted, and modified files. Users can navigate through layers, inspect file trees, compare changes between layers, and assess image efficiency with scores for wasted space and layer reuse.

Key benefits include identifying bloat in images, debugging build issues, and optimizing Dockerfiles by spotting unnecessary files or inefficient layering. The tool fetches image metadata and layers from Docker (or compatible runtimes like Podman or nerdctl), mounts layers temporarily for inspection, and supports custom commands for shell access within layers.

With color-coded diffs (green for added, red for removed, yellow for modified), build-time tracking, and global search, dive makes complex image internals accessible. It's particularly valuable for DevOps engineers, container builders, and security auditors checking for sensitive data leaks across layers. Written in Rust for speed and safety, it runs locally without external services.

CAVEATS

Requires Docker CLI or compatible runtime (Podman, nerdctl) with image pulled locally. Large images may consume significant disk space during analysis. Not for remote registry inspection without pull.

KEY FEATURES

TUI with layer diffs, efficiency analyzer, file search, custom shells.
Color-coded changes and build history overlays.

INSTALLATION

Linux: curl -sL https://github.com/wagoodman/dive/releases/latest/download/dive_*.deb or Cargo: cargo install dive.
Also via Homebrew, AUR.

USAGE TIPS

Run dive myimage:latest for TUI. Use Tab to switch panes, Enter for details, / for search.
Analyze efficiency before pushing images.

HISTORY

Developed by Wade Goodman in 2018 as dive on GitHub (wagoodman/dive). Gained popularity for Docker optimization; rewritten in Rust v0.6 (2019) for performance. Actively maintained with v0.10+ supporting multiple backends.

SEE ALSO

Copied to clipboard