First create AQL Script file (example.aql) that contains:
Then used the command below to make the call to retrieve the information created from the "aql" script:
The results to running the above command:
This then gives the size of each layer in the docker repository.
In addition this documentation provided can help for collecting all images in a repo as well using AQL.
Lastly, we can run this API to gather the Artifact Count/Size for the folders in the repo of our choosing. Same thing we would do in UI but more in an efficient way.
Example:
This is the command to run to gather the Artifact Count/Size for 'test-docker-remote-cache':
Output:
From this we can achieve the size of the Image with all the tags, and can sum up all the tags resulted from the query as well.
items.find( { "repo": {"$eq": "test-docker-remote-cache"}, "$and": [ {"type":"file"}, { "$and": [ {"path": {"$match": "*nginx*"}} ] } ] }) .include("name","path","size")
Then used the command below to make the call to retrieve the information created from the "aql" script:
curl -X POST -uadmin:<password> 'https://<ARTIFACTORY_URL>/artifactory/api/search/aql' -T example.aql
The results to running the above command:
{ "results" : [ { "path" : "library/nginx/1.24.0-alpine", "name" : "list.manifest.json", "size" : 1645 },{ "path" : "library/nginx/sha256__0bb91b50c42bc6677acff40ea0f050b655c5c2cc1311e783097a04061191340b", "name" : "manifest.json", "size" : 1571 },{ "path" : "library/nginx/sha256__7e4f9e3295d61e2d26b2b568c2e5d9707a50bbd69afaabdfea942bdd216183a8", "name" : "sha256__20779f060cd3ec277650210aa15654e9ad332ba27e4933f738febc7892f21610", "size" : 1788531 ##layer size },{ "path" : "library/nginx/sha256__0bb91b50c42bc6677acff40ea0f050b655c5c2cc1311e783097a04061191340b", "name" : "sha256__ad570474ca7c3653588972408b7f01499a4a6cd2d8bc9fb9e4f4ba332a61d11d", "size" : 25695730 },{ "path" : "library/nginx/sha256__7e4f9e3295d61e2d26b2b568c2e5d9707a50bbd69afaabdfea942bdd216183a8", "name" : "sha256__c41833b44d910632b415cd89a9cdaa4d62c9725dc56c99a7ddadafd6719960f9", "size" : 3261854 },{ "path" : "library/nginx/sha256__0bb91b50c42bc6677acff40ea0f050b655c5c2cc1311e783097a04061191340b", "name" : "sha256__d981f2c20c93e1c57a46cd87bc5b9a554be5323072a0d0ab4b354aabd237bbcf", "size" : 30052747 },{ "path" : "library/nginx/sha256__7e4f9e3295d61e2d26b2b568c2e5d9707a50bbd69afaabdfea942bdd216183a8", "name" : "sha256__e5382a11adf2600437da72df68012b6432b1eb0d03f7a107accccd3dab938912", "size" : 11139336 } ], "range" : { "start_pos" : 0, "end_pos" : 7, "total" : 7 }
This then gives the size of each layer in the docker repository.
In addition this documentation provided can help for collecting all images in a repo as well using AQL.
Lastly, we can run this API to gather the Artifact Count/Size for the folders in the repo of our choosing. Same thing we would do in UI but more in an efficient way.
Example:
This is the command to run to gather the Artifact Count/Size for 'test-docker-remote-cache':
curl -XPOST -uadmin:<password> localhost:8081/artifactory/api/artifactgeneral/artifactsCount -H "Content-type: Application/json" --data '{"name":"library","repositoryPath":"test-docker-remote-cache/"}'
Output:
{ "artifactsCount" : 22, "artifactSize" : "68.62 MB" }
From this we can achieve the size of the Image with all the tags, and can sum up all the tags resulted from the query as well.