Skip to content

Instantly share code, notes, and snippets.

@epcim epcim/docker_overlay.md
Last active Jan 9, 2020

Embed
What would you like to do?
docker

identify kubernetes pods with docker overlay2

(not the best output, but works)

TOP_STORAGE=$(du -hs /var/lib/docker/overlay2/* | grep -Ee '^[0-9]{3}[M]+|[0-9]G' | sort -h |tail -n 10 |tee -a /dev/stderr |awk '{print $2}'|xargs|sed 's/ /|/g')

docker inspect $(docker ps -q) | jq '.[]|.Config.Hostname,.Config.Labels."io.kubernetes.pod.name",.GraphDriver.Data.MergedDir,.hovno' | egrep -B2 "$TOP_STORAGE"

docker image inspect $(docker images -aq) | jq '.[]|.RepoDigests[0],.GraphDriver.Data.MergedDir,.hovno' |egrep -B2 "$TOP_STORAGE" 

# TOP_STORAGE=$(du -hs /var/lib/docker/overlay2/* | grep -Ee '^[0-9]{3}[M]+|[0-9]G' | sort -h |tail -n 10 |tee -a /dev/stderr |awk '{print $2}'|xargs|sed 's/ /|/g') 
522M    /var/lib/docker/overlay2/6853671b47d3ef99060f311925d3398e79e3bc26fe871d72e644b8069587c4b3
631M    /var/lib/docker/overlay2/3dcca422244861ff396899bc7d8e49f9b3d5f3bec33a58ddf2e8e2faf13e7e17
631M    /var/lib/docker/overlay2/45ca5c8ea8f752df6a554a735a25ab5009ffaf5724159a9e1a437d881d6bbb3f
631M    /var/lib/docker/overlay2/66fd27131f305496b6c603fb93f717560a50f3d756ee01ec1af035440cbabd7a
631M    /var/lib/docker/overlay2/72d3a0a17d55af360875867ef40e8e931b63d2cd5d05cf557acb2c9d29da813a
632M    /var/lib/docker/overlay2/368da01f2914f471122145bc2a47acbd388e7db6314ec9d5e721ae2297577f1a
634M    /var/lib/docker/overlay2/f04c9c1fae0db953e81ac7fa960a96e931683ae7474484d4a889ea69e53b84d1
658M    /var/lib/docker/overlay2/7537e271bc97c62241bc4186ebd1256aba2f80b8c5728c593b4205f9b6d7aa1f
684M    /var/lib/docker/overlay2/e7a120a7c2863d43518827aba0512a6ad0b3ece5569d1815df35fe10034da730
3.0G    /var/lib/docker/overlay2/8ca0d5c9c0ba097eb06f13bd345f788efc4c9fce59bf9d88acd973a5b86d06cc

# docker inspect $(docker ps -q) | jq '.[]|.Config.Hostname,.Config.Labels."io.kubernetes.pod.name",.GraphDriver.Data.MergedDir,.hovno' | egrep -B2 "$TOP_STORAGE"

"ver-pxcfv"
"/var/lib/docker/overlay2/f04c9c1fae0db953e81ac7fa960a96e931683ae7474484d4a889ea69e53b84d1/merged"
--
"master-2"
"ares2-848cc9459d-wfm5g"
"/var/lib/docker/overlay2/8ca0d5c9c0ba097eb06f13bd345f788efc4c9fce59bf9d88acd973a5b86d06cc/merged"
--
"master-2"
"obelix-nkhv2"
"/var/lib/docker/overlay2/7537e271bc97c62241bc4186ebd1256aba2f80b8c5728c593b4205f9b6d7aa1f/merged"
--
"master-2"
"kube-proxy-j45sh"
"/var/lib/docker/overlay2/72d3a0a17d55af360875867ef40e8e931b63d2cd5d05cf557acb2c9d29da813a/merged"
--
"master-2"
"kube-controller-manager-master-2"
"/var/lib/docker/overlay2/3dcca422244861ff396899bc7d8e49f9b3d5f3bec33a58ddf2e8e2faf13e7e17/merged"
--
"master-2"
"kube-scheduler-master-2"
"/var/lib/docker/overlay2/66fd27131f305496b6c603fb93f717560a50f3d756ee01ec1af035440cbabd7a/merged"
--
"master-2"
"kube-apiserver-master-2"
"/var/lib/docker/overlay2/45ca5c8ea8f752df6a554a735a25ab5009ffaf5724159a9e1a437d881d6bbb3f/merged"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.