簡體   English   中英

如何替換已棄用的 aws ecr get-login --registry-ids

[英]How to replace deprecated aws ecr get-login --registry-ids

我正嘗試按照此示例提取 Amazon SageMaker Pytorch 公共映像之一。 在示例中,他們使用 shell 腳本和 Dockerfile 來拉取-擴展-構建容器並將其推送到 ECR。 這是 shell 腳本:

# The name of our algorithm
algorithm_name=pytorch-extending-our-containers-cifar10-example

cd container

account=$(aws sts get-caller-identity --query Account --output text)

# Get the region defined in the current configuration (default to us-west-2 if none defined)
region=$(aws configure get region)
region=${region:-us-west-2}

fullname="${account}.dkr.ecr.${region}.amazonaws.com/${algorithm_name}:latest"

# If the repository doesn't exist in ECR, create it.

aws ecr describe-repositories --repository-names "${algorithm_name}" > /dev/null 2>&1

if [ $? -ne 0 ]
then
    aws ecr create-repository --repository-name "${algorithm_name}" > /dev/null
fi

# Get the login command from ECR and execute it directly
# ( PROBLEM 1 )
$(aws ecr get-login --region ${region} --no-include-email)

# Get the login command from ECR in order to pull down the SageMaker PyTorch image
# ( PROBLEM 2 )
$(aws ecr get-login --registry-ids 520713654638 --region ${region} --no-include-email)

# Build the docker image locally with the image name and then push it to ECR
# with the full name.

docker build  -t ${algorithm_name} . --build-arg REGION=${region}
docker tag ${algorithm_name} ${fullname}

docker push ${fullname}

但是,他們使用aws ecr get-login來訪問 ECR。 get-login現在已棄用,取而代之的是get-login-password並在 awscli 2.0.3 中運行此 shell 腳本。 失敗。 如果我理解正確,那么第一個命令(問題 1)可以替換為:

$(aws ecr get-login-password --region ${region} | docker login --username AWS --password-stdin ${account}.dkr.ecs.${region}.amazonaws.com)

但是,第二個命令需要標志--registry-idsget-login-password無法識別。 我如何替換此命令,以便我可以docker login以從外部 ECR 注冊表中提取其中一個 SageMaker 映像?

我將 (1) 替換為:

$(aws ecr get-login-password --region ${region} |docker login --username AWS --password-stdin ${account}.dkr.ecr.${region}.amazonaws.com)

和 (2) 與:

$(aws ecr get-login-password --region ${region} |docker login --username AWS --password-stdin 763104351884.dkr.ecr.${region}.amazonaws.com)

因此,registry-ids 替換了 {account}。 看起來舊 ID 已關閉,我將 520713654638 切換為 763104351884,還將 Dockerfiles 導入切換為:

FROM 763104351884.dkr.ecr.$REGION.amazonaws.com/pytorch-training:1.6.0-gpu-py36-cu101-ubuntu16.04

運行腳本成功拉取、構建和推送 docker 之后,我就可以繼續了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM