2020年12月19日星期六

Cannot talk to another container inside same task on ECS Fargate using awsvpc networking type

I am running a standard SPA frontend app and a node server in the same ECS task.

Everything that I have read about awsvpc can use localhost when 2 containers inside the same task are interfacing with each other.

However, with this set up I can't seem to return data from my node server to my UI. All my requests immediately fail. I have asserted that it is actually trying to hit localhost on my actual computer.

Browser failure: https://pasteboard.co/JFJLnLO.png

For testing purposes I exposed port 8080 to see if I could interact with the node server directly and that works as expected. I just cant get the UI to talk to it.

Any help would be much appreciated

EDIT:

My task definition looks like this:

  "containerDefinitions": [      {        "essential": true,        "image": "[my-account-id].dkr.ecr.eu-west-1.amazonaws.com/[my-account]/app-ui:latest",        "name": "app-ui",        "logConfiguration": {          "logDriver": "awslogs",          "options": {            "awslogs-group": "/ecs/app-ui",            "awslogs-region": "eu-west-1",            "awslogs-stream-prefix": "ecs",            "awslogs-create-group": "true"          }        },        "portMappings": [          {            "containerPort": 3000,            "hostPort": 3000,            "protocol": "tcp"          }        ]      },      {        "essential": true,        "image": "[my-account-id].dkr.ecr.eu-west-1.amazonaws.com/[my-account]/app-api:latest",        "name": "app-api",        "logConfiguration": {          "logDriver": "awslogs",          "options": {            "awslogs-group": "/ecs/app-api",            "awslogs-region": "eu-west-1",            "awslogs-stream-prefix": "ecs",            "awslogs-create-group": "true"          }        },        "portMappings": [          {            "containerPort": 8080,            "hostPort": 8080,            "protocol": "tcp"          }        ]      }    ],    "cpu": "256",    "executionRoleArn": "arn:aws:iam::[my-account-id]:role/AWSServiceRoleECS",    "family": "app",    "memory": "512",    "networkMode": "awsvpc",    "requiresCompatibilities": ["FARGATE"]  }        [1]: https://i.stack.imgur.com/S7zl3.png  


from Recent Questions - Stack Overflow https://stackoverflow.com/questions/65375387/cannot-talk-to-another-container-inside-same-task-on-ecs-fargate-using-awsvpc-ne Granttastic http://ifttt.com/images/no_image_card.png

没有评论:

发表评论