I have a sample development mode nodejs application. I've used the following for Dockerfile
FROM node:14-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
EXPOSE 5180
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]
Built an image and pushed it to aws ecr repo and created a cluster in ecs I defined a task and here I'm using dynamic port mapping (0 5180)since my requirement is to run multiple containers in a single EC2. The task is then made into a service using EC2 where I've used AWS load balancer.
I'm using an application load balancer with listeners 80 and health check at Working Directory as "/app" as mentioned in the Dockerfile. This has been attached the ECS service as well.
My problem is when tasks are running at a steady state and I checked the Load Balancer target group and the targets show healthy but when I tried to access my application using the DNS of ALB the browser is trying to reach the page and the page becomes blank after multiple refreshing I'm able to reach the page but this is not consistent.
I open the container's security group to all traffic and I tried accessing a single task with its dynamic port number and it's working but not with the ALB DNS.