I am trying to retrieve manifest using REST api from nvcr.io docker registry.
Based on what I found in https://github.com/NVIDIA/ngc-container-replicator/blob/master/python/nvidia_deepops/docker/registry/ngcregistry.py
I was able to retrieve the token using:
TOKEN=$(curl -v -X GET "https://authn.nvidia.com/token?scope=group/ngc" -H "Authorization: ApiKey <base_64_ngc_api_key>" -H "Accept: application/json" | jq -r '.token')
But I am still not able to retrieve manifest using:
curl -X GET -vvv -k https://nvcr.io:443/v2/nvidia/cuda/manifests/latest -H "Authorization: Bearer ${TOKEN}" -H "Accept: application/json" -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -H "Accept: application/vnd.docker.distribution.manifest.v1+prettyjws" -H "Accept: application/vnd.docker.distribution.manifest.v1+json"
Any clue on how to resolve that?
Find out the authentication realm and scope:
$ curl -si https://nvcr.io/v2/nvidia/cuda/manifests/latest | grep Authenticate
Www-Authenticate: Bearer realm="https://nvcr.io/proxy_auth",scope="repository:nvidia/cuda:pull,push"
Next get a bearer token to pull:
TOKEN=$(curl -s -X GET "https://authn.nvidia.com/token?service=registry&scope=repository%3Anvidia%2Fcuda%3Apull" -H "Authorization: ApiKey <your api key>" | sed 's/{"token":"//;s/".*//')
Then use the token for your query:
curl -s -H "Authorization: Bearer ${TOKEN}" https://nvcr.io/v2/nvidia/cuda/manifests/latest
Hope that helps!
I had to make a slight change to the sed call. For me the result of the authentication returned json as well, but started with
{“expires_in”:600,“token”:"ey…
TOKEN=$(curl -s -X GET "https://authn.nvidia.com/token?service=registry&scope=repository%3Anvidia%2Fcuda%3Apull" -H "Authorization: ApiKey <your api key>" | sed 's/{.*"token":"//;s/".*//')