gpt4 book ai didi

node.js - 无法从Docker Registry Remote API获得有效响应

转载 作者:行者123 更新时间:2023-12-02 21:25:08 25 4
gpt4 key购买 nike

我正在使用Nodejs和request进行API调用,我可以使用它直接对UnixSocket进行API调用,但是从正在运行的Docker注册表容器中进行请求时,每次尝试均会失败,因此我认为这是我的注册表配置的错误。

我已经按照下面的just like the doc步骤进行了设置。

docker run -d -p 5000:5000 --restart=always --name registry registry:2
docker pull alpine
docker tag alpine localhost:5000/alpine
docker push localhost:5000/alpine

我要请求的代码如下,它接收到 404 not found
  const request = require('request')
request({
method: 'GET',
uri: 'http://localhost:5000/images/json', // status 404
// uri: 'http://unix:/var/run/docker.sock:/images/json', // this works
headers: { host : 'localhost' }
}, (e, res, body) => {
if(e) return console.error(e)
console.log(res.statusCode == 200 ? JSON.parse(body) : res.statusCode)
})

需要明确的是,这段代码只是为了演示我正在发出一个格式正确的GET请求。

为了使正在运行的注册表容器能够响应远程API,必须做什么?

最佳答案

Docker Registry没有/images/json API,并且Docker Registry的API与docker engine API不兼容。

要获取Docker Registry的镜像列表,请尝试GET /v2/_catalog。完整文档可以在here中找到。

关于node.js - 无法从Docker Registry Remote API获得有效响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39759834/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com