Expected behavior
Run docker compose up
, navigate to my domain using HTTPS, and the app loads.
Actual behavior
Run docker compose up
, navigate to my domain using HTTPS, and the request hangs. The page never loads and eventually the browser shows “Server Not Found”.
Steps to reproduce the behavior
- Create a NLB using the aws CLI as described here in the Docker documentation: Deploying Docker containers on ECS | Docker Documentation
- Copy the NLB’s domain and create a CNAME DNS record for my domain
- Copy the NLB’s ARN and update the docker-compose.yml file to include
x-aws-loadbalancer
- Update docker-compose.yml file to specify SSL termination for the NLB as described here in the Docker documentation: Deploying Docker containers on ECS | Docker Documentation
- Change to the ecs context using
docker context use myecscontext
- Run
docker compose up
and wait for it to complete successfully - Navigate to my domain using HTTPS
The final docker-compose.yml file ends up with the following AWS configuration:
x-aws-loadbalancer: ${AWS_LOAD_BALANCER}
x-aws-cloudformation:
Resources:
AppTCP80Listener:
Properties:
Certificates:
- CertificateArn: ${AWS_SSL_CERTIFICATE}
Protocol: HTTPS
Port: 443
Additional Information
The steps described above work as expected if I do not specify x-aws-loadbalancer
and instead let Docker / AWS create a new load balancer; however, I want to use an existing NLB so that I don’t need to update my domain’s CNAME record between each deployment.