Docker Community Forums

Share and learn in the Docker community.

How do I use Restful API's to get container disk usage?


(Grandnexus123) #1

Hi, I’m looking at the docker api’s located https://docs.docker.com/engine/api/v1.37/#operation/SystemDataUsage and I’m wondering where in the JSON provided can I get the amount of disk space used by each container.
To be clear, I need to know the disk space used NOT INCLUDING the image size. So it should only be files written by whatever is running in the container or log files or temp files, not the image.

From the command “docker system df -v” I can get a pretty good table of all the containers and how much disk space they are using (if any), but I don’t see that reflected in the restful api’s.

The JSON I get back does not have useful disk size that I can tell though I’m not 100% sure.

I see the following:

  "SharedSize": 0,
  "Size": 6445006681,
  "VirtualSize": 6445006681

Which one of those tell me the amount of disk space that container is using minus the image size? Any ideas?

Docker version 18.03.1-ce, build 9ee9f40 running on RS4 on Windows 10.