使用 PrivilegedMode=TRUE 的 AWS 精选 Docker 图像创建 CodeBuild 项目

Creating a CodeBuild project using an AWS curated Docker image with PrivilegedMode=TRUE

我使用以下命令确认 aws/codebuild/java:openjdk-8 是精选的 CodeBuild 映像之一。

$ aws codebuild list-curated-environment-images | grep -A 1 openjdk-8
"name": "aws/codebuild/java:openjdk-8", 
"description": "AWS CodeBuild - Java 8"

尽管 aws/codebuild/java:openjdk-8 是一个精选图像,但当我尝试使用该图像和 PrivilegedMode=true 参数创建构建项目时,我收到一个没有意义的 4XX 错误:“PrivilegedMode can 仅为具有自定义或 AWS CodeBuild Docker 精选图像的项目设置。

9    [main] INFO  org.janusgraph.codepipelines.AwsCodePipelinesCi  -
{
    Name: j1pass-bdb-project,
    Source: {Type: CODEPIPELINE,},
    Artifacts: {Type: CODEPIPELINE, Name: null-artifacts,Packaging: NONE},
    Environment: {Type: LINUX_CONTAINER,
    Image: aws/codebuild/java:openjdk-8,
    ComputeType: BUILD_GENERAL1_LARGE,
    EnvironmentVariables: [{Name: MODULE,Value: janusgraph-berkeleyje}],
    PrivilegedMode: true},
    ServiceRole: arn:aws:iam::############:role/cbjanus,
    TimeoutInMinutes: 480
}
1454 [main] ERROR org.janusgraph.codepipelines.AwsCodePipelinesCi  -
PrivilegedMode can only be set for projects with custom or AWS CodeBuild Docker
curated images. (Service: AWSCodeBuild; Status Code: 400;
Error Code: InvalidInputException; Request ID: 89ab67a0-4d00-11e7-8da7-bdeb9326cb3c)
com.amazonaws.services.codebuild.model.InvalidInputException: PrivilegedMode can
only be set for projects with custom or AWS CodeBuild Docker curated images.
(Service: AWSCodeBuild; Status Code: 400;
Error Code: InvalidInputException; Request ID: 89ab67a0-4d00-11e7-8da7-bdeb9326cb3c)

AWS CodeBuild "Docker" 精选图像是以 "aws/codebuild/docker" 开头的图像。可在此处找到 CodeBuild 精选图像的完整列表:http://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref.html.

您只能为您的 "custom" 图片设置最近引入的这个标志。这些图像可能存在于您的私有 Amazon ECR 注册表或 public DockerHub 注册表中。关于如何在此处启用标志的示例:http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker-custom-image.html.

因此,对于您的示例,您会收到此错误,因为尽管您使用的 openjdk-8 图像是精选图像,但它不是 "docker" 精选图像。