How to link 2 docker containers one with backend code and other with react both are on node.js - node.js

I have 2 docker containers running one with node which is my backend code and another with react build running on node, how do I link between the containers so that my react API calls are fulfilled via my node backend container.
I'm running the containers using ECS and routing using ALB, both my containers are in different target groups and the same cluster.
Actual Result:-
Both the containers are running individually but there is no response to the API calls made using react.
Expected Result:-
API requests should be fulfilled using the other node container.

There is no way to link two different task definition, You should run both containers in one task definition. you can only link container if it is the single task definition otherwise you need to use service discovery or internal load balancer if the there is two different task definition and having two different target group so better to use an internal load balancer or service discovery.
If you want to configure in the same task definition then you can refer or access the container using container name along with port. But I will not suggest docker linking in case of AWS I think such an approach is not good for production.
One of the biggest disadvantages is that if you want to scale one container in the service, all the container will be the scale of the task definition.
You can link this way, Go to task definition -> Container -> Networking -> just add the name of the second container as pasted in the image.
You can explore here and here further about service discovery and load balancer.

Related

Azure Container Instance Pricing

I am trying to deploy a ASP net core web application in Azure Container Instance. Since it is having a microservice pattern I had to create 3 container groups for 2 API's and 1 for the web application. Each container group is having one application container and an nginx side cart to act as a reverse proxy. But I have getting around 120$ bill for these container instances alone. Each container is allocated 0.2GB Ram and 0.2GB CPU.
I am pretty new to Container instances and I am not sure if my approach is correct? Can any one suggest is it the right approach for hosting the application and also am I missing or misconfiguring some configurations while creating the container instances?

How to use the container name in rancher inside the application code running within the container

Having a nodejs application running inside a docker container orchestrated by Rancher. Using appdynamics to monitor the service. For that we need to add few configuration parameters in main js file. One of the configuration has to be unique for all the containers running for this service. So, i would like to pass the rancher container name as that configuration.

How does one deploy multiple micro-services in Node on a single AWS EC2 instance?

We are pretty new to AWS and looking to deploy multiple services into one EC2 instance.
Each micro-service is developed in its own repository.
Each service will have its own endpoint URL
Services may talk to each other
Services can be updated/deployed separately
Do we need a beanstalk for each? I hope not.
Thank you in advance
So the way we tackled a similar issue at our workplace was to leverage the multi-container docker platform supported by Elastic Beanstalk in most AWS regions.
The way this works in brief is, we had dedicated repositories for each of our services in ECR (Elastic Container Registry) where the different "versioned" images were deployed using a deploy script.
Once that is configured and set up, all you would need is deploy a Dockerrun.aws.json file which basically highlights all the apps you would want to deploy as part of the docker cluster into 1 EC2 instance (make sure it is big enough to handle multiple applications). This is the file where one would also highlight link between applications (so they can talk to one another), port configurations, logging drivers and groups (yea we used AWS CloudWatch for logging) and many other fields. This JSON is very similar to one's docker-compose.yml which is used to bring up your stack for local development and testing.
I would suggest checking out the sample example configuration that Amazon provides for more information. Also, I found the docker documentation to be pretty helpful in this regard.
Hope this helps!!
It is not clear if you have a particular tool in mind. If you are using any tool for deployment of a single micro-service, multiple should be the same.
How does one deploy multiple micro-services in Node on a single AWS
EC2 instance?
Each micro-service is developed in its own repository.
Services can be updated/deployed separately
This should be the same as deployment of a single micro-service. As long as they have different path and port that they are running on, it should be fine.
Each service will have its own endpoint URL
You can use nginx as a reverse proxy which can redirect your request from port 80 to the required port of your micro service.
Services may talk to each other
This again should not be an issue. You can either call them directly with the port number or via fully qualified name and come back via nginx.

Azure Docker Container Service Multiple Instances

I'm using Azure for the first time to deploy a web app. More specifically, I'm using the Docker Container Service to do this. I already have one instance of it deployed. But, I want to also deploy 2 more instances of the same web app. I want each instance to have a different URL. What is the best way of doing this? Do I have to add a new container service for each new instance and repeat the steps I did for deploying the first instance?
As in case of Azure Container Service (ACS),
You choose a container orchestrator i.e. Swarm, DC\OS and Kubernetes (Because creating replicas works differently in each of them).
In case of Swarm then either create a separate application container for the same application with a different end point and use automatic discovery feature for different URL(s) or choose a reverse-proxy load-balancer such as Nginx which will work on the same URL but on a different port (My blog here might help you).
Creating replicas across a cluster are used for Load Balancing, Routing Mesh, Scaling and Rolling updates etc.

Link containers in Azure Container Service with Mesos & Marathon

I'm trying to deploy a simple WordPress example (WordPress & MySQL DB) on Microsofts new Azure Container Service with Mesos & Marathon as the underlying orchestration platform. I already ran this on the services offered by Google (Kubernetes) and Amazon (ECS) and thought it would be an easy task on ACS as well.
I have my Mesos cluster deployed and everything is up and running. Deploying the MySQL container isn't a problem either, but when I deploy my WordPress container I can't get a connection to my MySQL container. I think this might be because MySQL runs on a different Mesos agent?
What I tried so far:
Using the Mesos DNS to get ahold of the MySQL container host (for now I don't really care which container I get ahold of). I set the WORDPRESS_DB_HOST environment var to mysql.marathon.mesos and specified the host of MySQL container as suggested here.
I created a new rule for the Agent Load Balancer and a Probe for port 3306 in Azure itself, this worked but seems like a very complicated way to achieve something so simple. In Kubernetes and ECS links can be simply defined by using the container name as hostname.
An other question that came up, what difference is their in Marathon between setting the Port in the Port Mappings Section and in the Optional Settings section. (See screenshot attached)
Update: If I ssh into the master node than I can dig by using mysql.marathon.mesos, how ever I can't get a connection to work from within an other container (in my case the wordpress container).
So there are essentially two questions here: one around stateful services on Marathon, the other around port management. Let me first clarify that neither has to do anything with Azure or ACS in the first place, they are both Marathon-related.
Q1: Stateful services
Depending on your requirements (development/testing or prod) you can either use Marathon's persistent volumes feature (simple but no automatic failover/HA for the data) or, since you are on Azure, a robust solution like I showed here (essentially mounting a file share).
Q2: Ports
The port mapping you see in the Marathon UI screen shot is only relevant if you launch a Docker image and want to explicitly map container ports to host ports in BRIDGE mode, see the docs for details.

Resources