名为 <IMAGE_URI> 的无效操作配置图像 URI 容器与提供的任务定义文件中缺少的任何容器都不匹配
Invalid action configuration Image URI container named: <IMAGE_URI> does not match any of the missing containers in the task definition file provided
我的管道出现此错误,我正在尝试测试 gree/blue 部署。我的任务定义如下所示。
"executionRoleArn": "arn:aws:iam::4634380474765:role/ecsTaskExecutionRole",
"containerDefinitions": [
{
"name": "containername",
"image": "<IMAGE_NAME>",
"essential": true,
"portMappings": [
{
"hostPort": 80,
"protocol": "tcp",
"containerPort": 80
}
]
}
],
"requiresCompatibilities": [
"FARGATE"
],
"networkMode": "awsvpc",
"cpu": "256",
"memory": "512",
"family": "myTaskDefination"
}
buildspec.yml
version: 0.2
phases:
pre_build:
commands:
- echo Logging in to Amazon ECR.....
- aws --version
- echo $$AWS_DEFAULT_REGION
- REPOSITORY_URI=account.dkr.ecr.ap-southeast-2.amazonaws.com/tv2testenv
- aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $REPOSITORY_URI
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- IMAGE_TAG=${COMMIT_HASH:=latest}
build:
commands:
- echo Build started on `date`
- echo Building the Docker image...
- docker build -t $REPOSITORY_URI:latest .
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
post_build:
commands:
- echo Build completed on `date`
- echo Pushing the Docker images...
- docker push $REPOSITORY_URI:latest
- docker push $REPOSITORY_URI:$IMAGE_TAG
- printf '{"ImageURI":"%s"}' $REPOSITORY_URI:$IMAGE_TAG > imageDetail.json
artifacts:
files:
- appspec.yml
- taskdef.json
- imageDetail.json
appspec.yml
version: 0.0
Resources:
- TargetService:
Type: AWS::ECS::Service
Properties:
TaskDefinition: <TASK_DEFINITION>
LoadBalancerInfo:
ContainerName: "Containername"
ContainerPort: 80
pipeline.json
{
"name": "Deploy",
"actions": [
{
"name": "Deploy",
"actionTypeId": {
"category": "Deploy",
"owner": "AWS",
"provider": "CodeDeployToECS",
"version": "1"
},
"runOrder": 1,
"configuration": {
"AppSpecTemplateArtifact": "BuildArtifact",
"ApplicationName": "odeDeploy",
"DeploymentGroupName": "DeploymentGroup",
"Image1ArtifactName": "BuildArtifact",
"Image1ContainerName": "<IMAGE_URL>",
"TaskDefinitionTemplateArtifact": "BuildArtifact"
},
"outputArtifacts": [],
"inputArtifacts": [
{
"name": "BuildArtifact"
}
],
}
]
}
错误是从上面的部分管道中抛出的,抱怨 Image1ContainerName。我似乎无法弄清楚我做错了什么。 Image1ContainerName 是不是应该是图像 url?
您将 CodePipeline 设置为使用 IMAGE_URI
作为动态更新任务定义。
当您的任务定义正在使用时:
"image": "<IMAGE_NAME>",
最简单的解决方案是将任务定义更改为使用
"image": "<IMAGE_URI>",
我的管道出现此错误,我正在尝试测试 gree/blue 部署。我的任务定义如下所示。
"executionRoleArn": "arn:aws:iam::4634380474765:role/ecsTaskExecutionRole",
"containerDefinitions": [
{
"name": "containername",
"image": "<IMAGE_NAME>",
"essential": true,
"portMappings": [
{
"hostPort": 80,
"protocol": "tcp",
"containerPort": 80
}
]
}
],
"requiresCompatibilities": [
"FARGATE"
],
"networkMode": "awsvpc",
"cpu": "256",
"memory": "512",
"family": "myTaskDefination"
}
version: 0.2
phases:
pre_build:
commands:
- echo Logging in to Amazon ECR.....
- aws --version
- echo $$AWS_DEFAULT_REGION
- REPOSITORY_URI=account.dkr.ecr.ap-southeast-2.amazonaws.com/tv2testenv
- aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $REPOSITORY_URI
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- IMAGE_TAG=${COMMIT_HASH:=latest}
build:
commands:
- echo Build started on `date`
- echo Building the Docker image...
- docker build -t $REPOSITORY_URI:latest .
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
post_build:
commands:
- echo Build completed on `date`
- echo Pushing the Docker images...
- docker push $REPOSITORY_URI:latest
- docker push $REPOSITORY_URI:$IMAGE_TAG
- printf '{"ImageURI":"%s"}' $REPOSITORY_URI:$IMAGE_TAG > imageDetail.json
artifacts:
files:
- appspec.yml
- taskdef.json
- imageDetail.json
appspec.yml
version: 0.0
Resources:
- TargetService:
Type: AWS::ECS::Service
Properties:
TaskDefinition: <TASK_DEFINITION>
LoadBalancerInfo:
ContainerName: "Containername"
ContainerPort: 80
pipeline.json
{
"name": "Deploy",
"actions": [
{
"name": "Deploy",
"actionTypeId": {
"category": "Deploy",
"owner": "AWS",
"provider": "CodeDeployToECS",
"version": "1"
},
"runOrder": 1,
"configuration": {
"AppSpecTemplateArtifact": "BuildArtifact",
"ApplicationName": "odeDeploy",
"DeploymentGroupName": "DeploymentGroup",
"Image1ArtifactName": "BuildArtifact",
"Image1ContainerName": "<IMAGE_URL>",
"TaskDefinitionTemplateArtifact": "BuildArtifact"
},
"outputArtifacts": [],
"inputArtifacts": [
{
"name": "BuildArtifact"
}
],
}
]
}
错误是从上面的部分管道中抛出的,抱怨 Image1ContainerName。我似乎无法弄清楚我做错了什么。 Image1ContainerName 是不是应该是图像 url?
您将 CodePipeline 设置为使用 IMAGE_URI
作为动态更新任务定义。
当您的任务定义正在使用时:
"image": "<IMAGE_NAME>",
最简单的解决方案是将任务定义更改为使用
"image": "<IMAGE_URI>",