Created
February 24, 2022 08:52
-
-
Save mysteriouss/d8b8bad7b36b06c24402d0a3f83c300d to your computer and use it in GitHub Desktop.
docker container overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# grab the size and path to the largest overlay dir | |
du /var/lib/docker/overlay2 -h | sort -h | tail -n 100 | grep -vE "overlay2$" > /tmp/large-overlay.txt | |
# make sure json parser is installed | |
# yum install -y jq | |
# apt-get install jq -y | |
# construct mappings of name to hash | |
docker inspect $(docker ps -qa) | jq -r 'map([.Name, .GraphDriver.Data.MergedDir]) | .[] | "\(.[0])\t\(.[1])"' > /tmp/docker-mappings.txt | |
# for each hashed path, find matching container name | |
cat /tmp/large-overlay.txt | xargs -l bash -c 'if grep $1 /tmp/docker-mappings.txt; then echo -n "$0 "; fi' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment