Home > Enterprise >  how to replace nginx default page in docker using dockerfile
how to replace nginx default page in docker using dockerfile

Time:06-07

I am trying to host a static site in docker using dockerfile

dockerfile

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

Docker command

docker build -t newwebsite .
docker run --name website -d -p 8080:80 newwebsite

But it still displays the nginx default page when run localhost:8080

Ho do I go about debugging this?

CodePudding user response:

Is there any content in the directory where you are running the docker build command?

COPY . /user/share/nginx/html This indicates that the contents are being copied from the current directory to a path in the Docker image.

Another way is to enter the running container and debug it.

(host) $ docker exec -it website /bin/bash
root@5bae70747b2c:/#

root@5bae70747b2c:/# ls -ltra /usr/share/nginx/html
total 20
-rw-r--r-- 1 root root  497 Jan 25 15:03 50x.html
drwxr-xr-x 1 root root 4096 May 28 05:40 ..
-rw-r--r-- 1 root root   48 Jun  7 03:50 Dockerfile
-rw-r--r-- 1 root root  135 Jun  7 03:51 index.html
drwxr-xr-x 1 root root 4096 Jun  7 03:51 .

The above is an example of serving index.html with Nginx, and you can check if there are contents in /usr/share/nginx/html like this.

  • Related