0
0
Dockerdevops~10 mins

System prune for cleanup in Docker - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - System prune for cleanup
Start: Docker system prune command
Check for unused containers
Check for unused images
Check for unused networks
Check for unused build cache
Remove all unused data
Display freed space
End
The system prune command checks for unused Docker data like containers, images, networks, and cache, then removes them to free space.
Execution Sample
Docker
docker system prune -f
This command removes all unused containers, images, networks, and build cache without asking for confirmation.
Process Table
StepActionEvaluationResult
1Run 'docker system prune -f'Identify unused containersList of stopped containers found
2Remove unused containersContainers removedSpace freed from containers
3Identify unused imagesDangling and unused images foundList of images to remove
4Remove unused imagesImages deletedSpace freed from images
5Identify unused networksNetworks not used by any container foundList of networks to remove
6Remove unused networksNetworks deletedSpace freed from networks
7Identify build cacheBuild cache foundCache to remove
8Remove build cacheCache deletedSpace freed from cache
9Display total space freedSummary shownUser sees total disk space reclaimed
10EndNo more unused dataCleanup complete
💡 All unused containers, images, networks, and build cache removed; system cleaned.
Status Tracker
Resource TypeStartAfter Prune
Containers (stopped)3 stopped containers0 stopped containers
Images (unused)5 dangling images0 dangling images
Networks (unused)2 unused networks0 unused networks
Build CacheSome cache dataNo cache data
Key Moments - 3 Insights
Why does the command remove stopped containers but not running ones?
The prune command only targets unused resources. Running containers are in use, so they are not removed. See execution_table rows 1 and 2 where only stopped containers are identified and removed.
What does the '-f' flag do in 'docker system prune -f'?
The '-f' flag forces the prune without asking for confirmation. This is why the command proceeds directly to removal steps in the execution_table without pause.
Does 'docker system prune' remove volumes?
By default, volumes are not removed. The command targets containers, images, networks, and build cache only. This is why volumes are not listed in the variable_tracker or execution_table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step are unused images removed?
AStep 5
BStep 3
CStep 4
DStep 2
💡 Hint
Check the 'Action' column for image removal in the execution_table.
According to the variable tracker, how many stopped containers remain after prune?
A3
B0
C1
D5
💡 Hint
Look at the 'Containers (stopped)' row under 'After Prune' in variable_tracker.
If the '-f' flag is removed, what changes in the execution flow?
AThe command will ask for confirmation before removal
BIt will remove volumes as well
CIt will skip removing networks
DIt will remove running containers
💡 Hint
Recall the explanation about the '-f' flag in key_moments and how it affects confirmation.
Concept Snapshot
docker system prune -f
Removes all unused containers, images, networks, and build cache
Does not remove volumes by default
-f skips confirmation prompt
Frees disk space by cleaning unused Docker data
Full Transcript
The 'docker system prune -f' command cleans up unused Docker resources. It first finds stopped containers, unused images, networks, and build cache. Then it removes them all without asking for confirmation because of the '-f' flag. Running containers and volumes are not removed. After completion, it shows how much disk space was freed. This helps keep your Docker environment clean and saves storage space.