NOTES INDEX This page is part of the collection of "notes" - these can be considered to be micro-blogs.
Finding docker container for overlay folder

Finding docker container for overlay folder

In folder’s /var/lib/docker/overlay2/* there is data stored per container. If for example your disk starts running out of space, and you find in the overlay2 folder which one is eating up the space, you might want to know for which docker container this was.

I found some suggestions on stackoverflow on how to do that, and collected them here for my own reference:

# you start off in /var/lib/docker/overlay2
cd /var/lib/docker/overlay2

# find the used disk space (biggest at end of list):
du -ms * | sort -n | tail


# and then use one of the next examples to find which container is the culprit:


# list overlay folders, you can grep in there (uses jq)
docker inspect $(docker ps -qa) |  jq -r 'map([.Name, .GraphDriver.Data.MergedDir]) | .[] | "\(.[0])\t\(.[1])"'

# list overlay folders, you can grep in there
docker inspect -f "{{.RepoTags}} {{.GraphDriver}}" $(docker images -q)

# alternative: list overlay folders, you can grep in there
docker inspect -f $'{{.Name}}\t{{.GraphDriver.Data.MergedDir}}' $(docker ps -aq)

# if above ones miss the folder, try the next command.
# On output, hit / (to search) and part of folder name, when found, browse up to find which container it is.
docker ps -qa | xargs -I{} bash -c "docker inspect {}" | less
Code language: PHP (php)

February 14, 2024

Leave a Reply

Your email address will not be published. Required fields are marked *