我正在尝试在AWS代码构建中构建一个docker容器,作为将容器部署到ECR的方法,但是我收到此错误。
Error while executing command: $(aws ecr get-login --region ap-southeast-1). Reason: exit status 255
此命令在buildspec.yml文件上运行,使用aws / codebuild / ubuntu-base:14.04并启用此标志,如果您要构建Docker镜像或希望您的构建获得提升权限。
日志文件如下:
[Container] 2018/10/11 00:52:49 Running command $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email)
An error occurred (AccessDeniedException) when calling the GetAuthorizationToken operation: User: arn:aws:sts::502776083946:assumed-role/code-build-timesheet/AWSCodeBuild-f1d205b1-b03f-4727-a4d7-a02118021eec is not authorized to perform: ecr:GetAuthorizationToken on resource: *
[Container] 2018/10/11 00:52:52 Command did not exit successfully $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email) exit status 255
[Container] 2018/10/11 00:52:52 Phase complete: INSTALL Success: false
[Container] 2018/10/11 00:52:52 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email). Reason: exit status 255
此状态代码通常表示未经授权的用户。要解决这个问题,我们需要让我们的代码构建角色能够与ECR
交谈。要做到这一点:去IAM
,然后将AmazonEC2ContainerRegistryPowerUser
政策附加到你的CodeBuild
角色。
您的cloudwatch日志中是否有更具体的错误?喜欢AccessDenied或其他什么?在失败的命令部分的日志中应该有一些细节。谢谢,辛