Docker/Clean Unused: Difference between revisions
< Docker
Created page with "== Clean Docker == {| class="wikitable" ! TODO || Command |- | Run debian image on Windows || <syntaxhighlight lang="bash"> # Git Bash winpty docker run --name=debian0 -it debian:12 # Power Shell docker run --name=debian0 -it debian:12 </syntaxhighlight> |- | Open shell of running container || <syntaxhighlight lang="bash"> docker exec -it mwdev-mediawiki-1 /bin/bash </syntaxhighlight> |- | Copy file from running container || <syntaxhighlight lang="bash"> docker cp mwde..." |
|||
| (5 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
== Clean | == Clean Images == | ||
{| class="wikitable" | {| class="wikitable" | ||
! | ! 🎯 Purpose || ⌨️ Command | ||
|- | |- | ||
| | | Clean all unused images || | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
sudo docker image prune -a | |||
</syntaxhighlight> | </syntaxhighlight> | ||
|- | |- | ||
| | | Clean unused images older than 30 days || | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
docker | sudo docker image prune -a --filter "until=720h" | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|- | |- | ||
| | | Clean unused containers, networks, images, and build cache || | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
docker | sudo docker system prune | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|- | |- | ||
| | | Clean all unused Docker resources || | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
docker | sudo docker system prune -a | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|- | |- | ||
| | | Clean all unused resources including volumes || | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
docker | sudo docker system prune -a --volumes | ||
</syntaxhighlight> | |||
|} | |||
== Clean Build Cache == | |||
{| class="wikitable" | |||
! 🎯 Purpose || ⌨️ Command | |||
|- | |- | ||
| | | Clean unused build cache || | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
sudo docker builder prune | |||
</syntaxhighlight> | </syntaxhighlight> | ||
|- | |- | ||
| | | Clean all unused build cache || | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="bash"> | ||
docker | sudo docker builder prune -a -f | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|- | |- | ||
| | | Clean build cache older than 30 days || | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
sudo docker builder prune -a --filter "until=720h" | |||
docker | |||
</syntaxhighlight> | </syntaxhighlight> | ||
|- | |- | ||
| | | Show Docker disk usage || | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="bash"> | ||
sudo docker system df | |||
docker | |||
</syntaxhighlight> | </syntaxhighlight> | ||
|- | |- | ||
| | | Build without using cache || | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="bash"> | ||
docker | sudo docker compose build --no-cache | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|} | |} | ||
Latest revision as of 02:21, 6 October 2026
Clean Images
| 🎯 Purpose | ⌨️ Command |
|---|---|
| Clean all unused images |
sudo docker image prune -a
|
| Clean unused images older than 30 days |
sudo docker image prune -a --filter "until=720h"
|
| Clean unused containers, networks, images, and build cache |
sudo docker system prune
|
| Clean all unused Docker resources |
sudo docker system prune -a
|
| Clean all unused resources including volumes |
sudo docker system prune -a --volumes
|
Clean Build Cache
| 🎯 Purpose | ⌨️ Command |
|---|---|
| Clean unused build cache |
sudo docker builder prune
|
| Clean all unused build cache |
sudo docker builder prune -a -f
|
| Clean build cache older than 30 days |
sudo docker builder prune -a --filter "until=720h"
|
| Show Docker disk usage |
sudo docker system df
|
| Build without using cache |
sudo docker compose build --no-cache
|