- Beginner
- Data and disk
How it works
Each docker build -t api . moves the api tag; the previous image keeps its layers on disk. docker image prune removes dangling images; docker image prune -a also removes every image no container uses, which will then have to be pulled or built again.
What breaks
An image used by a container, even a stopped one, cannot be removed without -f. And removing an image does not free the layers another image still shares, which is why the space reclaimed is often smaller than the sizes listed.
In a terminal
docker images --filter dangling=true
docker image prune -f
See it break, then fix it
Write the Dockerfile or the compose file, type the docker commands, and watch a simulated server run them through reboots, upgrades and traffic. Free to start.