← All posts

DevOps

dive: Explore Docker Image Layers and Cut the Bloat

dive explores a Docker image layer by layer, showing what each adds and helping you find wasted space to shrink it.

D DevOps

Docker images have a way of getting fat without anyone noticing - a package cache left in a layer, files added then deleted in a later step (but still weighing down the earlier one), a base image heavier than it needs to be. dive is the tool for seeing exactly that. It opens an image and lets you explore it layer by layer, showing which files each layer adds, modifies, or removes, and scoring how efficiently the image uses space.

See Inside Every Layer

You pick a layer and dive shows you the filesystem changes it introduced, so the cause of a bloated image becomes visible:

# Explore an image interactively dive my-image:latest # Build and analyze in one step dive build -t my-image .

Find the Wasted Space

dive highlights wasted space - files added in one layer and deleted in another still count against the image, and it points those out - plus an efficiency score you can even gate a CI build on. It's the difference between guessing why an image is 1.2GB and knowing which layer and which files are responsible.

Rough Edges and Limitations

  • Diagnosis, not the fix. It shows the bloat; shrinking it means editing your Dockerfile (multi-stage builds, cleanup, slimmer bases).
  • Interactive by nature. The exploration is a TUI, though the CI mode is scriptable.
  • Docker-centric. It's built around the Docker image format and daemon.

The next time an image is mysteriously huge, dive turns "why is this so big?" into a layer-by-layer answer you can act on.

Internal link suggestion: link "editing your Dockerfile" to the hadolint post, which lints those Dockerfiles for the same kind of issue.