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?
2
Answers
I already tried
docker system prune
, now I have tried alsodocker 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:
but the difference reported by
df -h
is 13 GB and the folders that I wanted to remove are gone.Docker falls back to
vfs
when the backing filesystem does not support one of the other graph drivers. This is commonly seen with Docker in Docker installs since there are no other graph drivers that work on top of an overlay mount (overlay on top of overlay isn’t supported).vfs
is simply a full copy of the filesystem for every layer, which uses a lot of space and is very slow (every new container is also a full copy).For overlay support, you need to ensure the docker root is on a supported backing filesystem. Documentation for that is at:
https://docs.docker.com/storage/storagedriver/select-storage-driver/#supported-backing-filesystems
There are two places images can be cached. In the builder itself, and in the local docker image cache if you didn’t push to a registry. The builder will be pruned with
docker buildx prune
. The local image cache can be pruned withdocker image prune
which would only delete untagged images. To include tagged images,docker image prune -a
will also delete any unused images. To be more selective, you can delete the individual images you created withdocker image rm $image
.