I created simple nodeJS application with docker and when I run it locally, everything works fine. I've installed Docker and Docker-Compose on my EC2 instance then deployed docker container on it but web-app is not accessible even through:
Test Project files: https://github.com/mostafanabil71/Simple-test-NodeJSApp-with-docker.git
Container on Instance logs
Dockerfile:
FROM node:10-alpine
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
WORKDIR /home/node/app
COPY package*.json ./
USER node
RUN npm install
COPY --chown=node:node . .
EXPOSE 8080
CMD [ "node", "app.js" ]
a. Docker version 26.1.4, build 5650f9b b. npm version 10.8.1 c. node version v12.22.9 d. Docker Compose version v2.27.1-desktop.1 e. npm express: 10.8.1 f. installed platform on EC2 is ubuntu-noble-24.04-amd64-server-20240423
problem was solved after lunching the Security groups and editing the inbound rules as below image and easily APP was accessible by entering IP:Port in the web URL