如何访问dockerregistryv2curl?

当我直接运行docker run -d -p 5000:5000 --restart=always --name registry registry:2 ,我可以通过curl localhost:5000/v2/_catalog访问registry。 但是在我使用TLS引用https://docs.docker.com/registry/deploying/保护registry之后。 像curl localhost:5000/v2/_catalog这样的命令无法使用。 那么我怎样才能使用curl访问registry呢? 应该添加一些选项吗? 就像我想使用curl --insecure --cert ~/cert.pem --key ~/key.pem https://$host:2376/_ping remote api一样,我可以使用curl --insecure --cert ~/cert.pem --key ~/key.pem https://$host:2376/_ping

如果你熟悉httpparty / ruby​​,你可以看看这个实现: https : //github.com/EugenMayer/docker_registry_cli/blob/master/requests/DockerRegistryRequest.rb

根据您在registry中使用的auth机制,您将需要添加basic-auth信息,或者,如果使用承载令牌,则需要validation每个请求,请参阅https://github.com/EugenMayer/docker_registry_cli/tree /主/ AUTH

这意味着,你首先发送一个GET请求,如果你得到一个401,你发送范围参数凭证到服务器: https : //github.com/EugenMayer/docker_registry_cli/blob/master/requests/DockerRegistryRequest.rb# L52

它或多或less是通常的JWT令牌实现。 因此,您将需要添加basic-auth标头来curl,或者每个作用域添加JWT标记(每个intent需要2个curl请求)。

对于JWT令牌auth,请参阅https://docs.docker.com/registry/spec/auth/jwt/

对于basic-auth,需要这个头文件: https : //github.com/EugenMayer/docker_registry_cli/blob/master/auth/BasicAuthService.rb#L27

curl像curl --cacert domain.crt https://myregistry.com:5000/v2/_catalog将工作。

    Interesting Posts