Docker Community Forums

Share and learn in the Docker community.

Docker integration with ECS

(Pcdinesh08) #1

HI All,
Please help me understanding Docker deployment in AWS.

I have a spring boot application, which has been dockerized, All I need to do is deploying this to an ECS cluster.

When I tried doing it, I am unable to establish connectivity between docker containers.

How does the docker networking work’s inside ECS Cluster?

In my case, I have 6 microservices (A, B, C, D, E, F). Where A & B has to be deployed in first ECS server, C & D has to be deployed in second ECS server. Where E & F has to be deployed on third ECS server.

In terms of connectivity, all microservices need to communicate the microservice A.

Please help me in understanding how should I create a task definition and service for above scenario.

(David Maze) #2

Exactly the same as the Docker networking works if you ran the same containers on the same EC2 hosts with docker run commands instead of via ECS. I believe you need to deploy your own overlay network or service-discovery system. I’ve run a setup where every container publishes a port on the host and Consul knows which container runs where and provides DNS.

For this very specific setup, you could:

(1) Make sure you’ve created a Route 53 DNS name for the “first server”
(2) Launch the first instance’s ECS agent with a custom attribute labeling it as such
(3) Launch task A with a placement constraint limiting it to that instance
(4) Make task A publishes its port
(5) Configure the other service to talk to port 12345, where those are the DNS name from step 1 and the TCP port from step 4

There are still-more-complicated setups where you deploy an ELB for every service. If you go this direction, you’re probably looking at using a tool like Terraform to deploy the whole stack.

(Michael Friis) #3

ECS is not a Docker product, I recommend asking questions on the AWS forums:

(Junius) #4

AWS forum would be a better place for ECS.

ECS has the similar ability to bind the container to one node. You could bind A & B to the first node and publish the ports. C & D could access A & B via the ip of the first node.

Other options are using AWS ELB, or Consul. Or you could register the container to AWS Route53, the services could access each other via the DNS name.

(Sam) #5

As mentioned ECS is just a wrapper around EC2 instances. with auto scaling.
a task starts one (more) a docker container(s) inside the ECS instances (EC2)

so, how would you write a script (task) to do this with EC2 instances?

I think you would create 3 services, (A+B), (C+D) and (E+F)

and you could use redis as the catalog of info on how to reach A from the other nodes.
the A+B host would be the redis server host.