我遇到了 ECS Fargate 上容器的问题,更具体地说,一个任务中的 2 个容器相互通信。
\n根据链接的文章(https://aws.amazon.com/blogs/compute/task-networking-in-aws-fargate/),一旦在任务中配置了两个容器,任务中的任何其他容器都应该能够只需使用localhost或127.0.0.1与该容器进行通信。
\n然而我可以\xe2\x80\x99t似乎得到这种行为。我尝试将其分解为最简单的形式 - 在 1 个容器上运行 nginx,端口映射为 80,并在另一个容器上运行一个简单的 curl 命令,但没有什么乐趣。
\n我是否缺少某些内容或一些配置,需要执行这些操作才能让 2 个容器通过localhost或127.0.0.1在 ECS 任务定义中进行通信?
\n具有 2 个容器的任务定义的 JSON 文件:
\n{\n"requiresCompatibilities": [\n "FARGATE"\n],\n"inferenceAccelerators": [],\n"containerDefinitions": [\n {\n "name": "container-a",\n "image": "******.dkr.ecr.eu-west-1.amazonaws.com/repository-a:latest",\n "memoryReservation": "2048",\n "cpu": "1024",\n "resourceRequirements": null,\n "essential": true,\n "portMappings": [\n {\n "containerPort": "5000",\n "protocol": "tcp"\n }\n ],\n "environment": null,\n "environmentFiles": [],\n "secrets": null,\n "mountPoints": null,\n "volumesFrom": null,\n "hostname": null,\n …Run Code Online (Sandbox Code Playgroud)