On https://docs.docker.com/engine/api/v1.42/#tag/Volume/operation/VolumeInspect stated that the response have UsageData for local driver.
I’m using Docker version 23.0.1, build a5ee5b1. OS is Debian 11
When running from cli or api
docker volume inspect 0b2ba7e3dfe8850197b5bb92b7ec9d7b9c678d907fd04fdaddf1d2146887d47a
both only shown the default key , no UsageData
Is there an option I need to flip to make it show the new info ?
The description for this element indicates the data is only present if a specific endpoint is used:
Usage details about the volume. This information is used by the
GET /system/df endpoint, and omitted in other endpoints.
docker system df accumulates the usage data of all local volumes, this will not give you the information you are looking for.
Though, you can query the rest endpoint mentioned in the documentation and get the usage data for all volumes:
curl --silent --unix-socket /var/run/docker.sock -H "Content-Type: application/json" -X GET http://localhost/v1.42/system/df | jq '.Volumes'
Note: I pipe the output to
jq and only print the volumes for a better readability.
I see, since the local volume default using umask 0700, I cannot check the total size with du without root. I thought the api is giving the info.
Guess using local-persist driver is more suitable. Thanks for the info.