I'm trying to solve a filesystem filling issue because of docker containers, therefore I'm trying to find containers from overlay2 sub-directories structure :
$ sudo find /var/lib/docker/overlay2/ -xdev -size +100M -ls | tail -1
1249766 116312 -r--r--r-- 1 root root 119095683 Jul 19 11:05 /var/lib/docker/overlay2/309cec9f854b2323ccadaf88603d5ee5e2a42e63da253e75645dbe067cf898a2/diff/var/www/intranet/portail_v2/.git/objects/pack/pack-5b2029d9dc4efc3443b7688e796cb88d6d2e38c3.pack
$ id=309cec9f854b2323ccadaf88603d5ee5e2a42e63da253e75645dbe067cf898a2
$ echo ${id:0:12}
309cec9f854b
Now I'm trying to find to which container it corresponds to :
$ sudo docker container ls -a | grep -i ${id:0:12}
$
I did not find anything, how can I do it ?
I'm not sure there's a direct way to map from a layer to an image, but you can do the reverse. Which means you can iterate over all of the images and containers: