This lab introduces the dive tool for analyzing Docker image layers.
dive is a tool for exploring each layer in a Docker image, helping you understand what’s changed in each layer and identify ways to optimize your images.
In this lab, we’ll create a multi-layer Docker image and use dive to inspect its layers.
By the end of this lab, you’ll understand how Docker images are built layer by layer and how to use dive for image analysis.
If dive is not installed locally, we can use it via Docker.
# Pull the dive imagedockerpullwagoodman/dive
Check if dive is installed locally. If not, we’ll alias it to run via Docker.
# Check if dive is installedif!command-vdive&>/dev/null
thenecho"dive could not be found, using Docker alias..."# Alias dive to run via Dockeraliasdive="docker run -ti --rm -v /var/run/docker.sock:/var/run/docker.sock docker.io/wagoodman/dive"fi