Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

1.2K
Vistas
The container does not exist in the task definition

on my CI i have configured the deploy on the AWS ECS environment via bash script

**deploy.sh**
[...]

aws ecs register-task-definition --cli-input-json file://./deploy/skeleton.json

TASK_DEFINITION_ARN=$(aws ecs --output text list-task-definitions --family-prefix "${PROJECT_NAME}" --sort DESC --query "taskDefinitionArns[0]")

aws ecs update-service \
    --cluster "${PROJECT_NAME}" \
    --service "${PROJECT_NAME}" \
    --task-definition "${TASK_DEFINITION_ARN}" \
    --force-new-deployment \
    --deployment-configuration "maximumPercent=200,minimumHealthyPercent=100" \
    --desired-count ${DESIRED_COUNT}

[...]

and

    **skeleton.json**
{
    "family": "backend",
    "executionRoleArn": "arn:aws:iam::000000000000:role/XXXX",
    "taskRoleArn": "arn:aws:iam::0000000:role/XXXX",
    "networkMode": "awsvpc",
    "containerDefinitions":
        [{
            "name": "csharp",
            "essential": true,
            "environment":[{
                "name" : "CONNECTIONSTRINGS__Redis",
                "value" : "XXXX"
                },
                {
                "name" : "CONNECTIONSTRINGS__Database",
                "value" : "XXX"
                },
                {
                "name" : "ASPNETCORE_ENVIRONMENT",
                "value" : "XXX"
                }],
            "image": "00000000.dkr.ecr.eu-west-1.amazonaws.com/prj/backend:643105ef",
            "portMappings": [
                {
                    "containerPort": 80,
                    "protocol": "tcp"
                }
            ],
            "logConfiguration": {
                "logDriver": "awslogs",
                "options": {
                    "awslogs-group": "/ecs/backend/",
                    "awslogs-region": "eu-west-1",
                    "awslogs-stream-prefix": "csharp"
                }
            }
        }],
    "requiresCompatibilities": [
        "FARGATE"
    ],
    "cpu": "256",
    "memory": "512"
}

when i try to deploy with update-service the cli answer with:

An error occurred (InvalidParameterException) when calling the UpdateService operation: The container backend does not exist in the task definition.

but if i change in the json the container name from csharp to backend, the deploy works.

is that a bug? thx

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

The container name you define in task_definition must match with the one in ecs_service's load_balancer configuration container_name. This will allow the load balancer to dynamically map the container ports and attach it to target groups. enter image description here enter image description here

over 4 years ago · Santiago Trujillo Denunciar

0

I'm answering this old question to point out some notes for the Googlers.

It seems that there are two problems related to this error message.

The first one is that the error itself is misguided, since the reason behind it is not related to the task definition directly and actually this is the Load Balancer (LB) complaining about the container name, it is trying to find in the task definition.

As the problem itself, While creating a LB, containerName is passed as a prop and in most cases it is one of the container names on the first task definition revision. Changing container names that are used while creating a LB, via creating new task revisions, would probably result in this error.

In this case, recreating the service and/or task definition would probably solve the problem.

over 4 years ago · Santiago Trujillo Denunciar

0

ECS allows you to define many containers inside one task definition, so the ELB needs to know what container to direct the traffic to, in order to do that, it stores the name of the container you set it up with during creation.

enter image description here

If you are getting this error, you are probably not including a container with the same Container Name so it's complaining of not knowing what to connect to inside that new task definition.

TL;DR

Rename the container name inside the task definition to be the same as the container defined in the currently running (or last successfully deployed) task definition.

enter image description here

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda