AMAZON ECR(1)Repository for Docker

本文详细介绍了如何在Amazon ECS中设置并部署Docker仓库,包括创建仓库、构建Docker镜像、升级ECSC创建任务定义、更新服务等步骤,并提供了关键命令和配置细节。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

AMAZON ECR(1)Repository for Docker

1 Prepare Repository for Docker
Login AMAZON Console
Click on ‘Amazon ECS’, click on ‘Repositories’

That is not git repository, my understanding is that it is docker repository. We need create one docker repository based on the name of our project.
Usually I already have that name configured in Makefile as follow:
IMAGE=sillycat/sillycat-billing-play
TAG=1.3
NAME=sillycat-billing-play
REPOSITORY=registry.sillycat.com

So the name should be sillycat/sillycat-billing-play, click on the button ‘Create repository'
Repository name: sillycat/sillycat-billing-play

Once we type the name there, the Repository URL will be: https://xxxxxxx.dkr.ecr.us-east-1.amazonaws.com/sillycat/sillycat-billing-play

Click on the ’Next’ button.

If you are the first hero doing these thing on the build server/local server/stage server. You need the first 2 steps as well.
> aws ecr get-login --region us-east-1

This command will generate the login command for you.
> docker login -u AWS -p xxxxxxxxxxxxxx -e none https://xxxxxxx.dkr.ecr.us-east-1.amazonaws.com


After that, we will just replace the URL in our Makefile
IMAGE=sillycat/sillycat-billing-play
TAG=1.3
NAME=sillycat-billing-play
REPOSITORY=https://xxxxxxx.dkr.ecr.us-east-1.amazonaws.com

#REPOSITORY=registry.sillycat.com

2 Build Docker Image

Update the codes before we build the image.
> git pull origin develop

Make the binary software build, since we are using scala play framework, the underline command in Makefile is
app-build:
sbt clean update compile package universal:packageZipTarball


Or we can easily type following command with the help of Makefile
>make app-build

Based on the base image and binary software, we build our release image
> make build

Till now, the release image is on our local server, we can test it, run it, debug it if we want. But here, we will push this release image to docker repository.
> make push-local

3 Upgrade ECS

Create Task Definition
Click on the ’Task Definitions’, find the task we have there like ’sillycat-billing-play’, select on that

Click on the button ‘Create new revision'

Click on the ‘Container Name’ like ’sillycat-billing-play'
Change the ‘Image’ value to “xxxxxxx.dkr.ecr.us-east-1.amazonaws.com/sillycat/sillycat-billing-play:1.3"

Click on the ’Save’/‘Create’ button. After that, you will see a new Task Definition name with a index number there like
sillycat-billing-play:5

Upgrade Service
Click on the ‘Cluster’ at top left.

Click on the ‘Cluster: sillycat-production’, actually that is our ECS cluster name.

Click on the service name like ‘BillingService'

On the top right, click on the button ‘Update’, update the ’Task Definition’ value to sillycat-billing-play:5’’, haha, usually, we just need to add up 1 number there.

Click on the button ‘Update Service'

Then, ECS will do that magic, it will speed up N new services, then switch the load balance to the new services. Finally it will take down the N old services.

References:
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值