0
0
Dockerdevops~10 mins

Analyzing image layers with dive in Docker - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Analyzing image layers with dive
Start dive on image
Load image layers
Display layer details
Show file changes per layer
Analyze wasted space
User navigates layers
Exit dive
The tool loads the Docker image layers, shows details and file changes per layer, highlights wasted space, and lets the user explore each layer interactively.
Execution Sample
Docker
dive my-image:latest
Runs dive to analyze the Docker image named 'my-image:latest' layer by layer.
Process Table
StepActionLayer LoadedFiles ChangedWasted Space DetectedUser Interaction
1Start dive commandN/AN/AN/ALoading image layers
2Load base layerLayer 1 (base)50 files added0 MBDisplay layer info
3Load second layerLayer 210 files modified2 MBHighlight wasted space
4Load third layerLayer 35 files deleted2.5 MBUser inspects files
5User navigates to Layer 2Layer 210 files modified2 MBShows detailed file diff
6User navigates to Layer 3Layer 35 files deleted2.5 MBShows detailed file diff
7Exit diveN/AN/AN/ASession ends
💡 User exits dive after inspecting layers and wasted space
Status Tracker
VariableStartAfter Step 2After Step 3After Step 4After Step 5After Step 6Final
Current LayerNoneLayer 1Layer 2Layer 3Layer 2Layer 3None
Wasted Space (MB)0022.522.50
Files Changed050 added10 modified5 deleted10 modified5 deleted0
Key Moments - 2 Insights
Why does dive show wasted space even if files are deleted in a layer?
Because Docker layers are immutable, deleting files in a later layer doesn't remove them from previous layers, so wasted space remains as shown in steps 3 and 4.
How can I tell which layer added or modified a specific file?
By navigating to each layer (steps 5 and 6), dive shows detailed file changes per layer, helping identify where files were added or changed.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the wasted space after loading Layer 3?
A2.5 MB
B0.5 MB
C2 MB
D0 MB
💡 Hint
Check the 'Wasted Space Detected' column at step 4 in the execution table.
At which step does the user inspect detailed file differences for Layer 2?
AStep 3
BStep 6
CStep 5
DStep 7
💡 Hint
Look at the 'User Interaction' column for when Layer 2 is selected.
If no files were deleted in Layer 3, how would the wasted space after step 4 change?
AIt would increase
BIt would decrease
CIt would stay the same
DIt would be zero
💡 Hint
Refer to the 'Wasted Space (MB)' in variable_tracker after step 4 and consider how deletions affect it.
Concept Snapshot
dive <image>  # Run dive on a Docker image
Shows each image layer's files and changes
Highlights wasted space from unused files
Navigate layers interactively to inspect
Helps optimize image size by spotting inefficiencies
Full Transcript
This visual execution shows how the dive tool analyzes Docker image layers. It starts by loading the image layers one by one, displaying files added, modified, or deleted in each layer. It calculates wasted space caused by leftover files that are no longer needed but still occupy space due to Docker's layer immutability. The user can navigate between layers to see detailed file changes. The session ends when the user exits dive after inspecting the image. Key points include understanding why deleted files still cause wasted space and how to identify which layer changed specific files.