top of page
Writer's pictureSiddhesh Kadam

Customize Nginx Docker Image Using Dockerfile

To create a Dockerfile for an Nginx image with a customized index.html page, you can follow the example below. This assumes you have your custom index.html file in the same directory as your Dockerfile.


Create a file named Dockerfile with the following content:

[root@siddhesh Build]# cat Dockerfile
FROM nginx:latest

COPY index.html /usr/share/nginx/html/

EXPOSE 80
[root@siddhesh Build]#

This assumes your index.html file is in the same directory as the Dockerfile. If it's in a different directory, adjust the COPY command accordingly.


Now, place your custom index.html file in the same directory as your Dockerfile. For example:

[root@siddhesh Build]# cat index.html
This is test page of builddevops.com
[root@siddhesh Build]#

Then, build the Docker image using the following command:

[root@siddhesh Build]# docker build -t nginx-custom-builddevops .

After building the image, you can run a container based on it with the following command:

[root@siddhesh Build]# docker run -p 443:80 nginx-custom-builddevops


This command maps port 443 on the host to port 80 on the container. You can adjust the port mapping according to your preferences. Now, if you open a web browser and navigate to http://localhost:443, you should see your custom Nginx page.


docker




コメント

5つ星のうち0と評価されています。
まだ評価がありません

評価を追加
bottom of page