You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何解决Invalid task definition:找不到匹配名称的容器定义问题

解决Error: Invalid task definition: Could not find container definition with matching name问题

这个错误的核心是你在某个配置中引用的容器名称,和任务定义里实际的容器名称不匹配,结合你提供的任务定义,给你几个排查方向:

  • 检查容器名称的拼写一致性
    你的任务定义里容器名称是app-server-con,请确认所有引用这个容器的地方(比如负载均衡目标组配置、ECS服务的容器名称指定、启动任务时的参数)里的名称和这个完全一致——大小写、连字符、后缀都不能错,比如别把con写成container,或者大小写写成App-Server-Con。

  • 确认使用的是正确的任务定义版本
    如果你之前修改过任务定义,要确保当前操作(比如创建服务、启动任务)用的是包含app-server-con这个容器的最新版本,别不小心用了旧的、没有这个容器名称的版本。

  • 多容器场景的依赖检查(当前场景暂不适用)
    要是任务里有多个容器,得检查dependsOn这类依赖配置里的容器名称是否正确,但从你提供的定义看只有一个容器,这条可以忽略。

你的任务定义容器部分如下:

"containerDefinitions": [
    {
      "dnsSearchDomains": null,
      "environmentFiles": null,
      "logConfiguration": null,
      "entryPoint": null,
      "portMappings": [
        {
          "hostPort": 80,
          "protocol": "tcp",
          "containerPort": 8000
        }
      ],
      "command": null,
      "linuxParameters": null,
      "cpu": 0,
      "environment": [],
      "resourceRequirements": null,
      "ulimits": null,
      "dnsServers": null,
      "mountPoints": [],
      "workingDirectory": null,
      "secrets": null,
      "dockerSecurityOptions": null,
      "memory": null,
      "memoryReservation": 500,
      "volumesFrom": [],
      "stopTimeout": null,
      "image": "dkr.ecr.ap-south-1.amazonaws.com/app-server-repo:c63619a84827c463f7d3c5a78da6280f9ea3efec",
      "startTimeout": null,
      "firelensConfiguration": null,
      "dependsOn": null,
      "disableNetworking": null,
      "interactive": null,
      "healthCheck": null,
      "essential": true,
      "links": null,
      "hostname": null,
      "extraHosts": null,
      "pseudoTerminal": null,
      "user": null,
      "readonlyRootFilesystem": null,
      "dockerLabels": null,
      "systemControls": null,
      "privileged": null,
      "name": "app-server-con"
    }
  ],

内容的提问来源于stack exchange,提问作者Jyoti Porwal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 18:01:17