dockeramazon-ec2dockerfile

Problem in accessing running deloyed container on EC2


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:

  1. Instance Public IPv4 address: 13.48.193.158 or
  2. Public IPv4 DNS: ec2-13-48-193-158.eu-north-1.compute.amazonaws.com

Test Project files: https://github.com/mostafanabil71/Simple-test-NodeJSApp-with-docker.git

EC2 Instance inbound rules: enter image description here

Container on Instance logs

enter image description here

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" ]

enter image description here

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


Solution

  • 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

    enter image description here