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.
The default VPC only has public subnets, and it doesn't have any NAT Gateways. That is the minimal requirements needed to use the x-aws-vpc flag, not what you setup in your custom VPC.
The error indicates that it is trying to attach the load balancer to both your public and private subnets, but of course it is getting an error because some of those subnets are in the same availability zone. To use the custom VPC you have created you need to read up on how to customize the CloudFormation template that gets generated by docker-compose. You'll need to run docker compose convert
and get the name of the load balancer that gets generated in the CloudFormation template, and then add some custom x-aws-cloudformation
code in the docker-compose file to specify exactly which subnets the load balancer should be connected to.