Our docker storage is mounted on /mnt/docker_storage. It is quickly filled up, but as you can see only a fraction of the total space used is accounted in docker system df. Even after doing a complete prune by deleting all containers, images, volumes, networks, build cache etc. There will be a huge amount left over in the overlay2 directory presumably from artifacts that weren’t cleaned up by an unknown culprit. Is there anyway to identify which images “own” which overlay2 directories? Ideally docker system prune would remove “unowned” overlay2 layers. Currently I have to stop docker. Prune everything, move overlay2 to overlay2bak, start deleting it in the background then resume docker. I have to do this about once a month. If this is the wrong forum I apologize, any help in redirecting me would be greatly appreciated.
This is just because we are currently building, but when absolutely nothing is being used. In fact when everything is completely deleted, overlay2 directory will be using like 80% of the drive with zero mounts. Please notice the discrepancy in the the df -h amounts used and what is reported by docker system df
df -h reports all space not just what’s in the overlay mount.
This is how overlays work. The mounts do not take space, they are just different views on top of the existing filesystem.
What docker system df reports it the actual space used by the containers/images. It does this by walking the tree and calculating the space and is more like du than df.
I’m talking about when there are no mounts. No images, no containers, docker isn’t running. I go into /mnt/docker_storage/overlay2 and du -sh and there are tons of directories using tons of space. Nothing is mounted.
Please don’t fixate on just the bash output I posted. I assure you I have run docker system prune -a -f --volumes docker builder prune -f etc. unmounted any overaly2 mounts. I’ve made sure there is nothing left in docker, but /mnt/docker_storage/overlay2 still takes up a huge amount of space.
I just wrote a script to find all overlay2//diff which are used by any image, and compared that to the overlay2//diff directories that exist, and there are 436 diff directories unused by any image (there are no containers)
Docker is 19.03.5
The node is from Thu Jan 14 19:52:39 2016, but I’ve completely blown away the overlay2 directory a couple of times within the last 4 months
Would you say that diff directories that are not referenced by any images are safe to delete? For me, if I delete something being used it’s not a big deal as this is just a build server that isn’t running any containers or hosting any permanent images.
I know I’m late to the party but I have this issue as well and it’s on a gitlab runner. docker system df shows no data yet in the /var/lib/overlay2 directory there is ~250GB of data. I just stopped docker and wiped that directory and restarted docker and seems to not have caused any issues. But how is all this data in that directory when a docker ps -a shows no images?
We are seeing the same. After pruning we see a huge amount of disk space still in use. We use XFS for the partition where we store docker data, I wonder if that has anything to do with this (slightly unconventional filesystem choice I guess).