Last active
November 3, 2024 16:51
-
-
Save markomitranic/59019319db534d981ca918c70cd9f1ce to your computer and use it in GitHub Desktop.
List human readable sizes for all docker volumes
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/bash | |
set -e | |
for d in `docker ps -a | awk '{print $1}' | tail -n +2`; do | |
d_name=`docker inspect -f {{.Name}} $d` | |
echo "=========================================================" | |
echo "$d_name ($d) volumes:" | |
VOLUME_IDS=$(docker inspect -f "{{.Config.Volumes}}" $d) | |
VOLUME_IDS=$(echo ${VOLUME_IDS} | sed 's/map\[//' | sed 's/]//') | |
array=(${VOLUME_IDS// / }) | |
for i in "${!array[@]}" | |
do | |
VOLUME_ID=$(echo ${array[i]} | sed 's/:{}//') | |
VOLUME_SIZE=$(docker exec -ti $d_name du -d 0 -h ${VOLUME_ID}) | |
echo "$VOLUME_SIZE" | |
done | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment