DOCKER_KEY=$(cat ~/.docker/config.json | jq '.auths["https://index.docker.io/v1/"].auth')

TOKEN=$(curl -X GET https://auth.docker.io/token?service=registry.docker.io&scope=repository:${REPO}:pull -H "Authorization: Basic ${DOCKER_KEY}") | jq -r .token

curl -s -X GET https://registry.hub.docker.com/v2/repositories/${REPO}/tags/ -H "Authorization: Bearer ${TOKEN}"

для GCP:

#!/usr/bin/env bash

GCP_PROJECT_ID=...
MY_IMAGE=...

USERNAME=_json_key
PASSWORD=$(cat keyfile.json)

TOKEN=$(echo "$USERNAME:$PASSWORD" | base64)

RESPONSE=$(curl --header "Authorization: Basic $TOKEN" "https://gcr.io/v2/token?service=gcr.io&scope=registry:$GCP_PROJECT_ID/$MY_IMAGE:*")

REGISTRY_TOKEN=$(echo $RESPONSE | jq -r '.token')

echo "Registry token: $REGISTRY_TOKEN"
curl --header "Authorization: Bearer $REGISTRY_TOKEN" "https://gcr.io/v2/$GCP_PROJECT_ID/$MY_IMAGE/manifests/latest"
echo

Для Yandex Cloud:


Enter your comment. Wiki syntax is allowed:
 
  • devops/docker_registry_auth_using_curl.txt
  • Last modified: 2022/04/28 06:08
  • by admin