gpt4 book ai didi

amazon-web-services - Docker compose ECS集成: load balancer is of type application,项目需要网络

转载 作者:行者123 更新时间:2023-12-03 07:11:27 26 4
gpt4 key购买 nike

我有一个 docker-compose.yml 文件,如下所示:

version: "3.8"
x-aws-loadbalancer: "arn:aws:elasticloadbalancing:my-load-balancer"
services:
fastapi:
image: username/auth:FastAPI
x-aws-pull_credentials: "arn:aws:secretsmanager:us-west-2:creds"
build: FastAPI
ports:
- "5555:5555"
nginx:
image: username/auth:nginx
x-aws-pull_credentials: "arn:aws:secretsmanager:us-west-2:creds"
build: nginx
ports:
- "80:80"
depends_on:
- fastapi
networks:
default:
external: true
name: my-sg

但是当尝试使用 docker compose up 将其与 ECS 集成时,我收到错误:

load balancer "arn:aws:elasticloadbalancing:my-load-balancer" is of type application, project require a network

我还尝试使用顶级 x-aws-vpc 属性提供 vpc,但收到了相同的错误。

什么

最佳答案

这是因为您正在使用端口 5555,docker-compose 无法知道该端口正在用于 HTTP,因此它假设您需要网络负载均衡器,因为 Application Load Balancer 仅支持HTTP。

the documentation对于 ECS docker-compose 集成:

If services in the Compose file only expose ports 80 or 443, anApplication Load Balancer is created, otherwise ECS integration willprovision a Network Load Balancer. HTTP services using distinct portscan force use of an ALB by claiming the http protocol withx-aws-protocol custom extension within the port declaration:

因此,按照我链接的文档中的示例,我会尝试将 FastAPI 服务声明更改为以下内容:

  fastapi:
image: username/auth:FastAPI
x-aws-pull_credentials: "arn:aws:secretsmanager:us-west-2:creds"
build: FastAPI
ports:
- "5555:5555"
x-aws-protocol: http

或者可以将其更改为以下内容,以更紧密地匹配文档中的示例:

ports:
- target: 5555
x-aws-protocol: http

关于amazon-web-services - Docker compose ECS集成: load balancer is of type application,项目需要网络,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71730149/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com