how to get the volume size in docker-py

0 votes
I need to find the space occupied by a volume in a container. In order to check whether it crossed the threshold or not. Suppose a container is mounted in myvolume1 and I need to get the total space used by it, free space available on it. From this, I need to check its threshold is less than 80%. I'm using docker-py for automation purposes.
Apr 8, 2020 in Python by anonymous
• 120 points
4,831 views

1 answer to this question.

0 votes

When you created one volume in docker using docker volume create command, it creates a persistent volume. Now this persistent volume will take space from your local system. So it depends on your local system's storage.

You can check size of your docker system.

$ docker system df
TYPE                TOTAL               ACTIVE              SIZE                RECLAIMABLE
Images              3                   3                   379.8MB             237.1MB (62%)
Containers          10                  0                   731.9MB             731.9MB (100%)
Local Volumes       2                   1                   12.82kB             0B (0%)
Build Cache         0                   0                   0B                  0B

If you want to check from where your containers take storage, you can inspect your volume.

$ docker volume inspect myvol1
    {
        "CreatedAt": "2020-04-07T14:56:31+05:30",
        "Driver": "local",
        "Labels": {},
        "Mountpoint": "/var/lib/docker/volumes/myvol1/_data",
        "Name": "myvol1",
        "Options": {},
        "Scope": "local"
    }

In my case, my container takes storage from /var/lib/docker/volumes/myvol1/_data and this file is available in my local system.

Hope this will clear your doubt.

answered Apr 8, 2020 by MD
• 95,460 points

Related Questions In Python

0 votes
1 answer

How to get the size of a string in Python?

If you are talking about the length ...READ MORE

answered Jun 4, 2018 in Python by aryya
• 7,460 points
1,408 views
0 votes
3 answers

How to get the current time in Python

FOLLOWING WAY TO FIND CURRENT TIME IN ...READ MORE

answered Apr 8, 2019 in Python by rajesh
• 1,270 points
2,096 views
0 votes
1 answer

How to get the current time in Python

>>> import datetime >>> datetime.datetime.now() datetime(2018, 25, ...READ MORE

answered Jul 25, 2018 in Python by Frankie
• 9,830 points
792 views
–1 vote
2 answers

How to find the size of a string in Python?

following way to find length of string  x ...READ MORE

answered Mar 29, 2019 in Python by rajesh
• 1,270 points
2,161 views
+2 votes
1 answer
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 58,020 points
2,735 views
0 votes
1 answer

how to solve the error : "ImportError: No module named Tkinter" in python.

Hi@Umama, If you are using Linux system, then ...READ MORE

answered Apr 27, 2020 in Python by MD
• 95,460 points
13,516 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP