在使用aws official document中指定的代码管道部署ECS时,两个docker映像正在推入ECR。一幅图像包含提交ID和最新标签,另一幅图像未加标签,如图像下方指定的那样。
在我可以看到的"buildspec.yml"
文件中,泊坞窗正在推送两张带有“最新标签”的图像,另一张带有提交ID标签的图像,如下所示
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- IMAGE_TAG=${COMMIT_HASH:=latest}
- docker push $REPOSITORY_URI:latest
- docker push $REPOSITORY_URI:$IMAGE_TAG
我的问题是
1)在ECR中,泊坞窗推入完成后,必须有两个带有"commit id"
标签的图像,另一个带有“最新”标签的图像。但是在ECR中,它显示的标签名称错误,请检查上面所附的图像。为什么一个图像显示时未加标签?
2)当我的任务定义仅使用最新标签来构建容器时,为什么需要推送两个带有提交ID和最新标签的图像。我不是只需要推送带有“最新”标签的docker镜像,为什么我需要推送具有commit id标签的镜像?
答案 0 :(得分:0)
回答我自己的帖子,希望有人能找到有用的信息:
1)在ECR中,根据aws文档完成docker push之后,必须有两个映像,一个映像带有“ commit id”标签,另一个映像带有“ latest”标签。但是在ECR中,它显示的标签名称错误,请检查所附图片。为什么显示一张未加标签的图像?
The reason why there is a untagged image is because when an existing image with a tag latest already exists its tag will be removed when a new image called latest is pushed to ECR, only one image will result from the 2 docker push commands, this is because they are tagged together. This helps when reviewing which latest image is in use by looking at the commit hash.
2)当我的任务定义仅使用最新标签来构建容器时,为什么需要推送两个带有提交ID和最新标签的图像。我不是只需要推送带有“最新”标签的docker镜像,为什么我需要推送具有commit id标签的镜像?
Pushing the second image adds the commit hash as a tag. Overtime as more images are added to the ECR repository it helps to have the commit hash as a tag to differentiate between previous latest images especially if a particular image is needed for a rollback.