From cb502cd4e894a78e723902a4d2f23174b69430ce Mon Sep 17 00:00:00 2001 From: vanderliang Date: Wed, 31 May 2017 14:18:42 +0800 Subject: [PATCH] Fix downloading image fails when build docker Generate a token for each download process to avoid token expired. Closes: #33441 Signed-off-by: vanderliang --- contrib/download-frozen-image-v2.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/download-frozen-image-v2.sh b/contrib/download-frozen-image-v2.sh index 37b5038938..43bbf7e3cf 100755 --- a/contrib/download-frozen-image-v2.sh +++ b/contrib/download-frozen-image-v2.sh @@ -157,6 +157,7 @@ while [ $# -gt 0 ]; do echo "skipping existing ${layerId:0:12}" continue fi + token="$(curl -fsSL "https://auth.docker.io/token?service=registry.docker.io&scope=repository:$image:pull" | jq --raw-output '.token')" curl -fSL --progress \ -H "Authorization: Bearer $token" \ "https://registry-1.docker.io/v2/$image/blobs/$layerDigest" \ @@ -229,6 +230,7 @@ while [ $# -gt 0 ]; do echo "skipping existing ${layerId:0:12}" continue fi + token="$(curl -fsSL "https://auth.docker.io/token?service=registry.docker.io&scope=repository:$image:pull" | jq --raw-output '.token')" curl -fSL --progress -H "Authorization: Bearer $token" "https://registry-1.docker.io/v2/$image/blobs/$imageLayer" -o "$dir/$layerId/layer.tar" # -C - done ;;