1

I am an AWS noob. I have a web server container and a selenium hub container. My web server needs to access the other container; I can do this on development environment using docker-compose (by default containers are exposed to each other by name). I am confused about how to do this by using AWS CloudFormation. There is "links" parameter in the ContainerDefinition but I think this uses the legacy docker link parameter. So I am reluctant to use it.

Any recommendation?

P.S: I don't want to open the selenium instance to public so using public hostnames/IPs is not an option.

3
  • 1
    How are you running these containers (EKS, ECS, directly on EC2 instances, Fargate)?
    – David Maze
    Jul 10, 2020 at 17:05
  • @DavidMaze I am using ECR, LaunchType: FARGATE. Edit: 'networkMode': 'awsvpc'. Jul 10, 2020 at 17:08
  • Have you tried creating a security group and specifying that same security group in the Task Defintion of each container?
    – Aaron
    Jul 10, 2020 at 18:57

3 Answers 3

2

While the links parameter is legacy in the pure Docker world, it is still the easiest way to connect containers in the AWS ECS world without relying on dedicated service discovery (for example Consul or Route 53).

The biggest caveat with using links is that circular links are not possible. In addition, the containers must run in the same task / service. The links parameter will not work across multiple tasks / services.

1
2

Ok I solved my problem. I followed this blog.

and placed 2 tightly coupled containers into the same task definition and i was just able to access the other container like : localhost:port.

It is working fine.

For others who face the same problem; this solution may not be the best for you if your containers are not tightly coupled and one day you may need to deploy them in separate machines.

But for me it is good.

0

Create a private DNS namespace and register your services in this namespace via DnsConfig. This will make your service addressable via domain name provided as Name. We use Type: A, TTL: 10 as DnsRecords configuration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.