我在ECR任务定义中使用最新标记时遇到问题,其中图像参数的值类似XXXXXXXXXXXX.dkr.ecr.us-east-1.amazonaws.com/reponame/web:latest.
我期望一旦在容器实例(注册到集群的EC2实例)上运行了新的服务实例(任务),此任务定义就会从ECR中提取带有最新标签的图像.
但是,就我而言,当我远程连接到容器实例并列出docker映像时,我可以看到它尚未从ECR中提取最新的发行版映像.
自从我更新了任务定义以使用显式定义版本标记的最新标记实例(即:v1.05)以来,最新标记在当前版本之后有两个发行版本.
我在这个集群上只有一个容器实例.
我的过程中可能会有一些怪癖,但是这个问题主要是关于这种最新情况在这种情况下应如何表现?
我的docker映像构建和标记,ECR推送,ECS任务定义更新以及ECS服务更新过程:
# Build the image with multiple tags
docker build -t reponame/web:latest -t reponame/web:v1.05 .
# Tag the image with the ECR repo URI
docker tag ${imageId} XXXXXXXXXXXX.dkr.ecr.us-east-1.amazonaws.com/reponame/web
# Push both tags separately
docker push XXXXXXXXXXXX.dkr.ecr.us-east-1.amazonaws.com/reponame/web:v1.05
docker push XXXXXXXXXXXX.dkr.ecr.us-east-1.amazonaws.com/reponame/web:latest
# Run only if the definition file's contents has been updated
aws ecs register-task-definition --cli-input-json file://web-task-definition.json
# Update the service with force-new-deployment
aws ecs update-service \
--cluster my-cluster-name \
--service web \
--task-definition web \
--force-new-deployment
使用任务定义文件:
{
"family": "web","containerDefinitions": [
{
"name": "web","image": "XXXXXXXXXXXX.dkr.ecr.us-east-1.amazonaws.com/reponame/web:latest","essential": true,"memory": 768,"memoryReservation": 512,"cpu": 768,"portMappings": [
{
"containerPort": 5000,"hostPort": 80
}
],"entryPoint": [
"yarn","start"
],"environment": [
{
"name": "HOST","value": "0.0.0.0"
},{
"name": "NUXT_HOST",{
"name": "NUXT_PORT","value": "5000"
},{
"name": "NODE_ENV","value": "production"
},{
"name": "API_URL","value": "/api"
}
]
}
]
}
最佳答案