CodeBuild 构建的 docker 构建阶段出错
error with docker build stage of CodeBuild build
我在 CodeBuild 构建过程的 BUILD 阶段收到以下错误:
"Error while executing command: docker build -t ..."原因:退出状态1
我有一个代码构建服务角色设置了 ecr 权限,aws ecr 登录阶段已经成功,我的 buildspec.yml 非常简单 - 几乎只是标准模板。运行时是亚马逊管理的 ubuntu 图像,标准。
Docker 构建可能会失败的任何原因以及任何人会建议进行故障排除吗?
谢谢
完整 buildspec.yml 文件:
version: 0.2
phases:
pre_build:
commands:
- echo Logging in to Amazon ECR...
- $(aws ecr get-login --no-include-email --region eu-west-1)
build:
commands:
- echo Building the Docker image...
- docker build -t maxmind:latest .
- docker tag maxmind:latest 381475286792.dkr.ecr.eu-west-1.amazonaws.com/maxmind:latest
post_build:
commands:
- echo Build completed on `date`
- echo Pushing the Docker image...
- docker push 381475286792.dkr.ecr.eu-west-1.amazonaws.com/maxmind:latest
完整错误信息(构建阶段):
COMMAND_EXECUTION_ERROR: Error while executing command docker build -t maxmind:latest .. Reason: exit status 1
完整错误信息(POST_BUILD阶段):
COMMAND EXECUTION_ERROR: Error while executing command: docker push 381475286792.dkr.ecr.eu-west-1.amazonaws.com/maxmind:latest. Reason: exit status 1
完整错误消息(日志流):
[Container] 2020/05/20 09:28:54 Running command docker build -t maxmind:latest .
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[Container] 2020/05/20 09:28:54 Command did not exit successfully docker build -t maxmind:latest . exit status 1
[Container] 2020/05/20 09:28:54 Phase complete: BUILD State: FAILED
我尝试过的东西
将 AmazonEC2ContainerRegistryPowerUser 策略附加到由我的构建过程创建的代码构建服务角色
根据评论。
有两个问题。第一个是在 CodeBuild 项目中没有使用 PrivilegedMode
模式。在 docker 容器中构建 docker 图像时需要该模式。
第二个问题是缺少权限 iam:DeletePolicyVersion
。
启用模式并添加缺少的权限,问题解决了。
我在 CodeBuild 构建过程的 BUILD 阶段收到以下错误:
"Error while executing command: docker build -t ..."原因:退出状态1
我有一个代码构建服务角色设置了 ecr 权限,aws ecr 登录阶段已经成功,我的 buildspec.yml 非常简单 - 几乎只是标准模板。运行时是亚马逊管理的 ubuntu 图像,标准。
Docker 构建可能会失败的任何原因以及任何人会建议进行故障排除吗?
谢谢
完整 buildspec.yml 文件:
version: 0.2
phases:
pre_build:
commands:
- echo Logging in to Amazon ECR...
- $(aws ecr get-login --no-include-email --region eu-west-1)
build:
commands:
- echo Building the Docker image...
- docker build -t maxmind:latest .
- docker tag maxmind:latest 381475286792.dkr.ecr.eu-west-1.amazonaws.com/maxmind:latest
post_build:
commands:
- echo Build completed on `date`
- echo Pushing the Docker image...
- docker push 381475286792.dkr.ecr.eu-west-1.amazonaws.com/maxmind:latest
完整错误信息(构建阶段):
COMMAND_EXECUTION_ERROR: Error while executing command docker build -t maxmind:latest .. Reason: exit status 1
完整错误信息(POST_BUILD阶段):
COMMAND EXECUTION_ERROR: Error while executing command: docker push 381475286792.dkr.ecr.eu-west-1.amazonaws.com/maxmind:latest. Reason: exit status 1
完整错误消息(日志流):
[Container] 2020/05/20 09:28:54 Running command docker build -t maxmind:latest .
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[Container] 2020/05/20 09:28:54 Command did not exit successfully docker build -t maxmind:latest . exit status 1
[Container] 2020/05/20 09:28:54 Phase complete: BUILD State: FAILED
我尝试过的东西
将 AmazonEC2ContainerRegistryPowerUser 策略附加到由我的构建过程创建的代码构建服务角色
根据评论。
有两个问题。第一个是在 CodeBuild 项目中没有使用 PrivilegedMode
模式。在 docker 容器中构建 docker 图像时需要该模式。
第二个问题是缺少权限 iam:DeletePolicyVersion
。
启用模式并添加缺少的权限,问题解决了。