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

ECS动态端口映射报错:port should be set when target type is instance 求助

ECS动态端口映射报错:port should be set when target type is instance 求助

我最近用Terraform配置ECS的时候,设置了这些内容:

任务定义层级

network_mode = "bridge"

容器层级

portMappings = [
  {
    hostPort = 0,    
    containerPort = 8080
  }
]

Terraform会先检查状态,让我确认变更,但确认之后就直接失败了,报错信息是:

Error: port should be set when target type is instance

我发现网上搜出来的几十条相关建议,好多都是互相矛盾的,现在完全搞不清到底哪里出问题了。

我甚至都不确定containerPortRange这个参数该怎么用——到底是要在哪里设置?有没有必要设置?很多教程里根本没提它,但直觉上用它应该是个不错的选择。不过从名字来看("container"对应容器,"host"对应宿主机),它应该是用来指定容器端口的?而且在我这个场景里,感觉这个参数好像无关紧要?如果有人能给我把这部分讲清楚就太好了。

另外我还在想,会不会用awsvpc网络模式和bridge模式效果一样,能解决这个问题?

备注:内容来源于stack exchange,提问作者Dustin Oprea

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.16 12:58:09