docker compose to ecs complaining about load balancer issue

0

hi Guys,

I am trying to deploy docker into ecs using docker compose. Below is my docker compose file:

version: '3.8'
x-aws-vpc: "vpc-0fef56fb4ec32ad70"
services:
  osticket:
    container_name: osticket-web
    image: osticket/osticket
    environment:
      MYSQL_HOST: db
      MYSQL_PASSWORD: secret
    depends_on:
      - db
    ports:
      - 80:80
  db:
    container_name: osticket-db
    image: mariadb
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: secret
      MYSQL_DATABASE: osticket
      MYSQL_USER: osticket
      MYSQL_PASSWORD: secret

My VPC is private with 6 subnet (2 public, 4 private), 2 NAT gateways both in public subnets and has one internet gateway. I assume this was the minimal requirements needed to use the x-aws-vpc flag in docker compose and that rest of the resources would be created automatically.

When I run the docker compose up command, I get the below error:

A load balancer cannot be attached to multiple subnets in the same Availability Zone (Service: AmazonElasticLoadBalancing; Status Code: 400; Error Code: InvalidConfigurationRequest; Request ID: d2142a38-55c6-44ef-a405-e34d99d9fa07; Proxy: null)

PS: if I run the same docker compose with the default vpc, it works fine. so I'm not sure what else I am missing.

asked 2 years ago1057 views
2 Answers
1

As the error suggests, you cannot use more than one subnet for the same availability zone. In VPC, each subnet is associated with an availability zone. Please make sure to use another subnet in another AZ to have multiple subnets for the load balancer.

You enable one or more Availability Zones for your load balancer when you create it. If you enable multiple Availability Zones for your load balancer, this increases the fault tolerance of your applications. You can't disable Availability Zones for a Network Load Balancer after you create it, but you can enable additional Availability Zones.

Note that you can select only one subnet per Availability Zone.

AWS
Taka_M
answered 2 years ago
profile pictureAWS
EXPERT
reviewed 2 years ago
0

Thanks guys,

so now, I have added the 2 public subnets to my compose file:

version: '3.8'
x-aws-vpc: "vpc-0f64c8ba9cb5bb10f"
x-aws-subnets:
  - subnet-044ddbc9a47c8744a
  - subnet-0a16347f784acfb76

services:
  osticket:
    container_name: osticket-web
    image: osticket/osticket
    environment:
      MYSQL_HOST: db
      MYSQL_PASSWORD: secret
    depends_on:
      - db
    ports:
      - 80:80
  db:
    container_name: osticket-db
    image: mariadb
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: secret
      MYSQL_DATABASE: osticket
      MYSQL_USER: osticket
      MYSQL_PASSWORD: secret

But I am still getting the same error: A load balancer cannot be attached to multiple subnets in the same Availability Zone (Service: AmazonElasticLoadBalancing; Status Code: 400; Error Code: InvalidConfigurationRequest; Request ID: c742256e-4938-420e-ad97-63f75fb73979; Proxy: null)

Am I suing the x-aws-subnets in a wrong context or place?

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions