brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: docker buildx du shows what the Docker build cache holds

Docker
~/tips/tip-docker-buildx-du-build-cache

docker buildx du

List build cache entries with size and last use before you prune them.

docker system df gives one line for the build cache, often many gigabytes. docker buildx du breaks that down per cache record, with sizes and when each was last used.

docker buildx du
docker buildx du --verbose | less

The plain form prints a table with ID, RECLAIMABLE, SIZE and LAST ACCESSED, and totals at the bottom for shared, private and reclaimable space. With --verbose each record also shows its description, often the Dockerfile step that created it, so you can see which project the big entries belong to.

Cache mounts from RUN --mount=type=cache are kept apart and can be listed on their own:

docker buildx du --filter type=exec.cachemount

I think it is worth a look before running docker builder prune, because it shows whether the space sits in old one-off builds or in a cache you still use every day.

The numbers are per builder. If you created a separate buildx builder, for example a docker-container one for multi-platform builds, its cache lives inside that builder and only shows up with --builder name. A RECLAIMABLE value of false means the record is in use and a prune will not free it.

Further reading: docker buildx du, Build cache garbage collection

More Docker tips ONBUILD RUN /usr/local/bin/python-build --dir /app/src SHELL ["/bin/bash", "-c"] docker commit <container> myname/testimage:version3 docker import /path/to/exampleimage.tgz docker compose events All Docker tips (192) All topics

Link