Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find to which container or image a docker AUFS diff folder belongs to

Tags:

docker

Does anyone knows how to find to which docker container, image or volume an AUFS diff folder belongs?

I have a legacy file like this

/var/lib/docker/aufs/diff/d4f388f19d7b4e8e9eef2a4ae5630f87d59180263482fbc63dbe7d31b6c0fc5b/usr/lib/gcc/x86_64-linux-gnu/6/cc1

There's no container, volume or image with this ID d4f388f19d7b

I tried to find it inspecting each container, volume and image using the ID d4f388f19d7b but no luck

for c in $(docker ps -q) ; do docker inspect $c | grep d4f388f19d7b ; done
empty response

for i in $(docker images -q) ; do docker image inspect $i | grep d4f388f19d7b ; done
empty response

for v in $(docker volume ls -q) ; do docker volume inspect $v | grep d4f388f19d7b ; done
empty response

Is there an easy way to identify which docker container/volume/image owns this file? lsof shows that the file is not in use as it's a legacy file last time accessed was 3 months ago.

I am out of ideas

like image 200
Hernan Garcia Avatar asked Nov 20 '17 20:11

Hernan Garcia


1 Answers

I found the way to map a diff folder to a container

grep DIFF_FOLDER_ID /var/lib/docker/image/aufs/layerdb/mounts/*/mount-id

it will give you the container ID, if you get empty output it means is orphaned or it belongs to a docker image

like image 193
Hernan Garcia Avatar answered Sep 19 '22 13:09

Hernan Garcia