简体   繁体   English

如何将Docker容器映像更新从AWS ECR部署到ECS?

[英]How to deploy docker container image updates from AWS ECR to ECS?

I'm new to both Amazon's ECS and docker, and I don't know how to deploy new images. 我是亚马逊的ECS docker的新手,我不知道如何部署新的图像。

I currently create a new image in ECR with 我目前在ECR中创建了一个新图像

NAME_TAG=my-image-name:my-tag-v1
ECR=my-acct-number.dkr.ecr.us-east-1.amazonaws.com

docker build -t $NAME_TAG .
docker tag -f $NAME_TAG $ECR/$NAME_TAG
$(aws ecr get-login --region us-east-1) #log in
docker push $ECR/$NAME_TAG

At this point I don't know how to deploy the new container from ECR to my cluster. 此时我不知道如何将新容器从ECR部署到我的集群。

I created the cluster, task and service using a Cloud Formation template, but updating the TaskDefinition image to $ECR/$NAME_TAG and running a stack update eventually times out and fails with a “service did not stabilize” error. 我使用Cloud Formation模板创建了集群,任务和服务,但是将TaskDefinition图像更新为$ECR/$NAME_TAG并且运行堆栈更新最终超时并且因“服务未稳定”错误而失败。

If I push to my-image-name:latest , my cluster instances do pull down the new image, but they don't run it, and in any case I want to avoid using the mysterious latest tag. 如果我推送到my-image-name:latest ,我的集群实例拉下新图像,但它们不运行它,无论如何我想避免使用神秘的latest标签。

How am I supposed to deploy new images to ECS? 我该如何向ECS部署新图像?

You should be able to deploy your image using a new task definition every time you deploy. 每次部署时,您都应该能够使用新的任务定义部署映像。 The task definition lets you set the image version using the attribute "image" 任务定义允许您使用属性“image”设置图像版本

"image":"my-acct-number.dkr.ecr.us-east-1.amazonaws.com/my-image-name:my-tag-v1"

In case you want to use only one task definition, you will have to build you image and tag it with whatever is defined in the the definition. 如果您只想使用一个任务定义,则必须构建映像并使用定义中定义的任何内容对其进行标记。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM