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.
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 first-server.internal.zone 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.
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.
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.