Added first version of data volume information script

pull/4/head
Guido Diepen 2017-04-25 10:08:07 +02:00
rodzic 8bfc28ca03
commit b4c25c1871
1 zmienionych plików z 29 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,29 @@
#!/bin/bash
echo "List of all volumes:"
for docker_volume_id in $(docker volume ls -q)
do
echo " (Un)named volume: ${docker_volume_id}"
docker_volume_size=$(docker run --rm -t -v ${docker_volume_id}:/volume_data ubuntu bash -c "du -hs /volume_data | cut -f1" )
echo " Size: ${docker_volume_size}"
num_related_containers=$(docker ps -a --filter=volume=${docker_volume_id} -q | wc -l)
if (( $num_related_containers > 0 ))
then
echo " Connected containers:"
docker ps -a --filter=volume=${docker_volume_id} --format "{{.Names}} ({{.Status}})" | while read containerDetails
do
echo " ${containerDetails}"
done
else
echo " No connected containers"
fi
echo
done