1

enter image description hereDocker file contains the following command

FROM nginx
COPY . /usr/share/nginx/html

To build my docker image i have used following command

docker build -t <tagName>/img .

To run the docker image

docker run -p 80:8080 <tagName>/img

But i am not able to lanch my static site in my browser . i am getting

This site can’t be reached
localhost refused to connect.

enter image description here

2 Answers2

1

You are mapping port 80 to 8080 here: docker run -p 80:8080 <tagName>/img, so to access your app just use the address: 'localhost:80' (or you can ommit the port since 80 is the default port used in browsers)

Kimi Marie
  • 11
  • 2
1

While Kimi Marie is totally correct, the nginx Dockerfile provides port 80 inside the container. So I assume you would like to map the container's port 80 to your local port 8080. You just need to flip the params like

docker run -p 8080:80 <tagName>/img
boppy
  • 1,753
  • 12
  • 10
  • do you have any idea about this question https://stackoverflow.com/questions/65124243/static-web-application-in-docker-using-nginx-deployed-in-aws-ec2] – Saravana Kumar Dec 03 '20 at 19:37