Skip to content

Instantly share code, notes, and snippets.

@mysteriouss
Created February 24, 2022 08:52
Show Gist options
  • Select an option

  • Save mysteriouss/d8b8bad7b36b06c24402d0a3f83c300d to your computer and use it in GitHub Desktop.

Select an option

Save mysteriouss/d8b8bad7b36b06c24402d0a3f83c300d to your computer and use it in GitHub Desktop.

Revisions

  1. mysteriouss created this gist Feb 24, 2022.
    15 changes: 15 additions & 0 deletions overlay.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    #!/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'