大网数据广告活动
服务器运维问答

Amazon ECS Load balancer set to port 9090 doesnt work

· 52CE 我爱测

I have created classical load balancer in Amazon Web Services and I have given the listener port as 9090. And I have associated the load balancer with a cluster with 2 EC2 instances. I have given the inbound rules for the instanc…

问题原文

原帖链接 · Lahiru Liyanapathirana · CC BY-SA 3.0

I have created classical load balancer in Amazon Web Services and I have given the listener port as 9090. And I have associated the load balancer with a cluster with 2 EC2 instances. I have given the inbound rules for the instances for 9090 as well.

And in order to create a service in the cluster I have created a task definition as follows.

{
  "family": “my-spring-task“,
  "containerDefinitions": [{
    "image": “my-docker-group/my-spring-app“,
    "name": "my-spring-app",
    "cpu": 10,
    "memory": 256,
    "essential": true,
    "portMappings": [{
      "containerPort": 9090,
      "hostPort": 9090
    }]
  }]
}

Then I create the service, with the above task definition given.

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

aws ecs create-service --cluster service90-cluster --service-name service90-service --load-balancers loadBalancerName=service90-load-balancer,containerName=my-spring-app,containerPort=9090 --task-definition service90-task  --role ecs-service-role --desired-count 0

My plan is to run a Spring Boot project, which is build with gradle and docker plugin.

I have the project running port 8080. And it is working as expected. But when I try to run a service on port 9090 it doesn't work due to the failing of the health check.

I need advice as to how to make the port to 9090. or any port number.

已采纳解答

原帖链接 · Jason Martin · CC BY-SA 3.0

Most likely the port inside the container is still 8080, unless you reconfigured spring boot itself to use 9090. In that scenario you'll want to set containerPort to 8080 and leave hostPort at 9090.

Alternatively you can leave hostPort blank, and ECS will assign a random 'high' port to each container, then attach that to the ALB. This has the benefit of relieving you of needing to map port assignments in your ECS cluster, and multiple instances of the same container can run on the same host.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-12-15)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。