How do ECS containers communicate between each others?


I use docker compose ecs integration.
In AWS docker context, docker compose up did a deploy correctly.
But reverse proxy doesn't work correctly, maybe because of communication with containers.

My docker-compose.yml

version: '3'
    image: {ACCOUNT}.dkr.ecr.{REGION}.amazonaws.com/{MY_IMAGE}
      - "80:80"

    image: {ACCOUNT}.dkr.ecr.{REGION}.amazonaws.com/{MY_REACT_IMAGE}
    working_dir: /src
    command: sh -c "yarn install && yarn build && yarn start"
      - "3000:3000"

MY nginx.conf

server {
    listen 80;
    server_name localhost;
    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
        proxy_pass http://localhost:3000/;
        # proxy_pass http://nodeapp:3000/; // works only for local
        # proxy_pass http://nodeapp.{MY CLUSTER}.local:3000/; // doesn't work


My understandings

  1. In the same ECS service, containers can communicate with each other by localhost.
  2. In the diffrent ECS service, containers can communicate with each other by service discovery.

Are these correct? And, how do I do that?

1: The same ECS service

I tried to do that at first. But, docker compose up(ecs integration) created different services(for nginx service and application(react) service. How do I configure that?

2: The different service

In nginx conf, proxy_pass http:nodeapp.{MY_CLUSTER}.local:3000 doesn't work correctly.

How do ECS containers communicate between each others?
Let me know the simplest way.
Thanks in advance.

1 Answer 1


Understanding 1 is not correct, localhost is only for internal containers not other can access on localhost, if they share same network name can be used, nodeapp:3000 will work on local.

For different services we have to call them by local IP or a domain name if not in same network.

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.