My /var/lib/docker/overlay
directory contains data for my containers but the directory names are all hashed. How can I determine which container owns which overlay?
Overlay filesystems (also called union filesystems) is a fundamental technology in Docker to create images and containers. They allow creating a union of directories to create a filesystem. Multiple filesystems, which are just directories, are superposed one on top of another to create a new filesystem.
The overlay network driver creates a distributed network among multiple Docker daemon hosts. This network sits on top of (overlays) the host-specific networks, allowing containers connected to it (including swarm service containers) to communicate securely when encryption is enabled.
You can use jq
like so:
docker inspect $(docker ps -qa) | jq -r 'map([.Name, .GraphDriver.Data.MergedDir]) | .[] | "\(.[0])\t\(.[1])"'
Which gives:
/traefik_traefik_1 /var/lib/docker/overlay/58df937e805ec0496bd09686394db421c129e975f67180e737d5af51751af49c/merged
/gitlab-runner /var/lib/docker/overlay/4e5b06f4ee09c60e2dad3a0ce87352cead086eb8229775f6839a477b46dce565/merged
/rancher-agent /var/lib/docker/overlay/6026bb65dd9a83c2088a05cff005a1dd824494222445bab46b7329dc331465aa/merged
Explanation:
docker inspect $(docker ps -qa)
Display full docker details.
jq -r
Parse json and output regular strings:
map([.Name, .GraphDriver.Data.MergedDir])
For each element in the original array, find the Name
and the overlay MergedDir
.
"\(.[0])\t\(.[1])"
Output the first two elements of the array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With