如何替换已弃用的aws ecr get login--registry id



我正试图按照这个例子提取一个AmazonSageMaker 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-ids,而get-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)

因此注册表ID替换了{帐户}。看起来旧的id也关闭了,我将520713654638切换到763104351884,还将Dockerfiles导入切换到:

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

在那之后,运行脚本成功地拉、构建和推送了docker,我就可以继续了。

相关内容

  • 没有找到相关文章

最新更新