• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

477
Views
How do I link 2 containers running in a AWS ECS task

I am new to ECS and I am trying to deploy a couple of containers in a ECS task using Fargate.

I have 1 container running that uses Angular2 and is running on nginx, the other container is the backend and is running on Springboot and uses the port 42048.

I am using the awsvpc network with Fargate and I have to do it that way.

The Angular app communicates with the backend using localhost:42048/some_url and it works fine in my local docker but in AWS the front-end doesn't find the backend. Currently I have my ports mapped with 80 for the front end and 42048 for the backend and the front-end when deployed locally was able to find the backend as localhost:42048

Any help would be appreciated. Thank you

about 3 years ago · Santiago Trujillo
2 answers
Answer question

0

linking is not allowed in AWSVPC.

You can do linking only in network mode when its set to bridge.

links

Type: string array

Required: no

The link parameter allows containers to communicate with each other without the need for port mappings. Only supported if the network mode of a task definition is set to bridge. The name:internalName construct is analogous to name:alias in Docker links. Up to 255 letters (uppercase and lowercase), numbers, hyphens, and underscores are allowed. For more information about linking Docker containers, go to https://docs.docker.com/engine/userguide/networking/default_network/dockerlinks/. This parameter maps to Links in the Create a container section of the Docker Remote API and the --link option to docker run.

Note

This parameter is not supported for Windows containers or tasks using the awsvpc network mode.

Important

Containers that are collocated on a single container instance may be able to communicate with each other without requiring links or host port mappings. Network isolation is achieved on the container instance using security groups and VPC settings.

task_definition_parameters

In network mode, you have to define two containers in the same task definition and then mentioned the name of the container in the link.

enter image description here And then Mentioned the name of backend container in frontend container.

enter image description here

about 3 years ago · Santiago Trujillo Report

0

With Fargate, If you want to access your backend using localhost:42048, then you can try configuring your Frontend and Backend in the same Task definition. While deploying the task, all the containers defined in the same task definition would run in the same underlying host and we can access it using localhost. Remember that Fargate storage is ephemeral and your backend shouldn't maintain application state in the container.

...
"containerDefinitions": [
    {
      "name": "frontend",
      "image": "my-repo/angularapp",
      "cpu": 256,
      "memory": 1024,
      "essential": true,
      "portMappings": [ {
          "containerPort": 8080,
          "hostPort": 8080
       }
     ]
    },
    {
      "name": "backend",
      "image": "my-repo/springboot",
      "cpu": 256,
      "memory": 1024,
      "essential": true,
      "portMappings": [ {
          "containerPort": 42048,
          "hostPort": 42048
       }
     ]
    }
  ]
...  

But I'm afraid this approach isn't suitable for production grade.

about 3 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error