Created
February 26, 2018 19:57
-
-
Save fkorotkov/6244b7ec42b8f9b7e41986438fd913e3 to your computer and use it in GitHub Desktop.
JSON key file to Google Container Registry's HTTP API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What is the format of the keyfile? Where can the content be found in .docker/config.json ?