Search code examples
python-3.xshelldockerdocker-volume

How can I monitor docker volume usage?


I'm planning to automate docker activities using python. However, I couldn't find any efficient command for monitoring docker volume. So now I wish to use shell commands for that and later it can be converted using subprocess in python.

My requirement is when I give a volume name then I need the used space, free space, and total space of that volume for finding the storage threshold of the same.

I tried using the docker system df -v But it showing all details.

For example, I give the volume name as my_volume then I need storage details of the same only. Hope everyone understood my requirement and excepting a helping hand from someone


Solution

  • I give the volume name as my_volume then I need storage details of the same only.

    docker volume inspect 3459dffe0e309e11b3a09262dcd43ca3f54ee033ed01415a2bffad14faa8811d | jq -r .[].Mountpoint | xargs du -hs
    

    Seems to properly output the size of 3459dffe0e309e11b3a09262dcd43ca3f54ee033ed01415a2bffad14faa8811d volume.