Connecting localstack docker container from node js app container

Viewed 845

I am trying to connect localstack docker container from app container. I am using docker-compose file which looks something like below. await this.s3Client.send(command) is failing with Error: Unable to connect to instance metadata service

   localstack:
    image: ${AWS_ACCOUNT_ID}.dkr.ecr.ap-southeast-1.amazonaws.com/localstack:latest
    restart: always  
    ports:
      - '4566:4566'
    expose:
      - '4566'
    networks:
      - service-network
  app:  
    depends_on:    
      - localstack
    build: .
    command:
      - /bin/sh
      - -c
      - |
        npm run build      
        node .
    ports:
      - '3001:3001'
    volumes:
      - '.:/home/node/app'
    environment:
      - S3_ENDPOINT=http://localstack:4566
    networks:
      - service-network
      

I tried to run same app outside the docker container and connected to localstack running(http://localhost:4566)in the container. It was successful.

Could you please help how can I connect to localstack container from inside app container.

0 Answers
Related