mirror of
https://github.com/gdiepen/docker-convenience-scripts.git
synced 2025-04-28 10:13:41 +01:00
Added comments
This commit is contained in:
parent
0eccb0dd4d
commit
0fa2dd8502
1 changed files with 7 additions and 2 deletions
|
@ -4,18 +4,23 @@
|
||||||
echo "List of all volumes:"
|
echo "List of all volumes:"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
|
#Loop over all the data volumes
|
||||||
for docker_volume_id in $(docker volume ls -q)
|
for docker_volume_id in $(docker volume ls -q)
|
||||||
do
|
do
|
||||||
echo "(Un)named volume: ${docker_volume_id}"
|
echo "(Un)named volume: ${docker_volume_id}"
|
||||||
|
|
||||||
|
#Obtain the size of the data volume by starting a docker container
|
||||||
|
#that uses this data volume and determines the size of this data volume
|
||||||
docker_volume_size=$(docker run --rm -t -v ${docker_volume_id}:/volume_data ubuntu bash -c "du -hs /volume_data | cut -f1" )
|
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}"
|
echo " Size: ${docker_volume_size}"
|
||||||
|
|
||||||
|
#Determine the number of stopped and running containers that
|
||||||
|
#have a connection to this data volume
|
||||||
num_related_containers=$(docker ps -a --filter=volume=${docker_volume_id} -q | wc -l)
|
num_related_containers=$(docker ps -a --filter=volume=${docker_volume_id} -q | wc -l)
|
||||||
|
|
||||||
|
#If the number is non-zero, we show the information about the container and the image
|
||||||
|
#and otherwise we show the message that are no connected containers
|
||||||
if (( $num_related_containers > 0 ))
|
if (( $num_related_containers > 0 ))
|
||||||
then
|
then
|
||||||
echo " Connected containers:"
|
echo " Connected containers:"
|
||||||
|
|
Loading…
Add table
Reference in a new issue