我通过以下命令确认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可以仅为具有自定义或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。
您只能为您的“自定义”图片设置此标记(最近引入)。这些是您的私有Amazon ECR注册表或公共DockerHub注册表中可能包含的图像。在此处启用标记的示例:http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker-custom-image.html。
因此,对于您的示例,您会遇到此错误,因为尽管您使用的openjdk-8图像是策展图像,但它不是“docker”策展图像。