用于获取Top Docker Hub映像的API?

时间:2017-04-15 13:39:44

标签: docker docker-registry dockerhub

我想知道是否有用于获取Top Docker Hub映像的API?

就像我们打开https://hub.docker.com/explore/

时所获得的一样

我查了一下:

https://docs.docker.com/engine/api/v1.28/#https://docs.docker.com/registry/spec/api/

但是没找到我想要的东西。

1 个答案:

答案 0 :(得分:5)

https://hub.docker.com/explore/开始,调用以下API:

https://hub.docker.com/v2/repositories/library/?page=1&page_size=15

默认过滤器是通过降序拉计数,它会给你以下响应:

{
    "count": 139,
    "next": "https://hub.docker.com/v2/repositories/library/?page=1&page_size=15",
    "previous": null,
    "results": [{
        "user": "library",
        "name": "nginx",
        "namespace": "library",
        "repository_type": "image",
        "status": 1,
        "description": "Official build of Nginx.",
        "is_private": false,
        "is_automated": false,
        "can_edit": false,
        "star_count": 5777,
        "pull_count": 618674944,
        "last_updated": "2017-04-06T16:35:19.178373Z",
        "build_on_cloud": null
    },
    ...
    ...
   ]
}

因此,以下内容将为您提供在码头集线器上拉出的前100个泊坞窗图像:

https://hub.docker.com/v2/repositories/library/?page=1&page_size=100

page_size的最大大小为100(每页100个),count是此端点可以提供的最大数量(对于所有页面)。

例如使用curljq JSON解析器:

curl -s "https://hub.docker.com/v2/repositories/library/?page=1&page_size=100" | \
    jq '.results'

现在有https://store.docker.com的内部API可以从商店或dockerhub查询图片。 dockerhub中最受欢迎的产品可以通过以下方式检索:

https://store.docker.com/api/content/v1/products/search?page_size=100&q=%2B&source=community&type=image%2Cbundle

请求结果有一个popularity数字字段。要通过降序流行度过滤图像:

curl -s "https://store.docker.com/api/content/v1/products/search?page_size=100&q=%2B&source=community&type=image%2Cbundle" | \
    jq '.summaries | sort_by(-.popularity)'