How to find which folder under overlay2 directory belong to which container?

How to find which folder under overlay2 directory belong to which container?

If you’ve been working with Docker, you might have wondered where Docker actually stores the filesystems of your containers on your host machine. This information can be crucial for various reasons, such as debugging, storage optimization, or general curiosity.

Well, with a simple one-liner, you can get a neat list of all your containers along with their storage directories. Here it is:

for container in $(docker ps --all --quiet --format '{{ .Names }}'); do echo "$(docker inspect $container --format '{{.GraphDriver.Data.MergedDir }}' | grep -Po '^.+?(?=/merged)'  ) = $container"; done

Run this command in your terminal, and it will output a list in the following format:

/path/to/container/storage = container_name_1/path/to/container/storage2 = container_name_2...

More useful commands: https://github.com/PBujakiewicz/kubectl-oc-cheat-sheet/tree/main

Dodaj komentarz

Twój adres e-mail nie zostanie opublikowany. Wymagane pola są oznaczone *

Witryna wykorzystuje Akismet, aby ograniczyć spam. Dowiedz się więcej jak przetwarzane są dane komentarzy.