dockerbuildx

How can I recover disk space after having used buildx?


I have Docker 24.0.4 on Centos 7. I have tried to generate some big multiplatform images and now I have 10 GB of wasted space that I don't know how to reclaim.

Following this tutorial I have executed

docker buildx create --use --name buildx_instance

then I built some images (docker buildx build --platform linux/amd64,linux/arm64 ...) and finally I tried to clean everything with:

docker buildx stop buildx_instance
docker buildx rm buildx_instance
docker buildx prune
docker system prune

But I noticed that 10 GB are still missing, so I examined Docker's folders with ncdu and I found some big subfolders of docker/vfs/dir that clearly contain files of the images I have just built with buildx.

The tutorial says that images created with buildx

won't be visible under docker images and these images will be in buildx cache only

so how can I delete them? I don't want to use a brute force approach (stop/delete/reinstall everything). And how can I associate each subfolder of docker/vfs/dir to the right image?

Note also that I don't know why my Docker is using vfs instead of overlay2; I discovered it searching for the wasted space. The file /etc/docker/daemon.json contains only

{
  "data-root": "/docker"
}

because /var is in a very small filesystem.

I have another Centos 7 machine with Docker 23.0.6 without /etc/docker/daemon.json: it has the overlay2 folder instead of vfs. I used buildx on this machine too, in the same way, and I don't see wasted space. Why? What's the difference?


Solution

  • I already tried docker system prune, now I have tried also docker system prune -a and it solved my problem.

    It deleted all not-running images (expected and unwanted but acceptable) and some "build cache objects" then said:

    Total reclaimed space: 4.332GB
    

    but the difference reported by df -h is 13 GB and the folders that I wanted to remove are gone.