gpt4 book ai didi

amazon-ecs - 在 ECS 部署中更新 Docker 镜像

转载 作者:行者123 更新时间:2023-12-04 08:14:29 28 4
gpt4 key购买 nike

我在 AWS ECS 上部署了一个 CloudFormation 堆栈,比如 teststack , 通过命令

aws cloudformation deploy --template-file ./CloudFormationTemplate.yml --stack-name teststack --force-upload
我的堆栈执行某个 Docker 镜像,比如 myname/myimage:latest .
我想通过管道部署和更新堆栈(我正在使用 GitLab,但我想这与这里感兴趣的问题无关)。
在这个设置中,我可以在不接触 CloudFormation 模板文件的情况下修改我的 Docker 镜像;然后我构建并推送新镜像 myname/myimage:latest到我的注册表;最后,我触发了一个新的管道,它再次启动命令 aws cloudformation deploy ... --force-upload .
执行时 aws cloudformation deploy ... --force-upload , 管道返回 No changes to deploy. Stack stack-name is up to date .
显然,由于堆栈正在执行 latest标记的图像,它返回所有内容都是最新的,无需使用新的 latest图片。
有没有办法强制 AWS CloudFormation 从我的注册表中提取新的 Docker 镜像?

最佳答案

正在使用除 latest 以外的标签这里有一个选择?如果是这样,那么您可以标记要更新的最新更改,例如 myname/myimage:0-0-1然后更新 cloudformation 模板中的容器定义以使用这个新标签。
如果您想继续使用 latest标记您可能无法通过 cloudformation 模板更新强制部署。在我的项目中,当我不想更改标签时,我最终使用 AWS CLI 进行了更新:

aws ecs update-service --service ${ecsService}  --cluster ${ecsCluster} --region ${region} --force-new-deployment

关于amazon-ecs - 在 ECS 部署中更新 Docker 镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65776723/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com