mirror of
https://github.com/gdiepen/docker-convenience-scripts.git
synced 2025-01-18 01:58:54 +00:00
Added first version of data volume information script
This commit is contained in:
parent
8bfc28ca03
commit
b4c25c1871
29
docker_get_data_volume_info.sh
Normal file
29
docker_get_data_volume_info.sh
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user