Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Docker volume to modify index.html in Nginx Docker Image

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use Docker volume to modify the index.html in the Nginx Docker image". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use Docker volume to modify the index.html in the Nginx Docker image".

We all know that after running a Docker-based Nginx image, you can visit localhost to see the default home page of Nginx, which is located under the / usr/share/nginx/html directory within the Nginx image.

Suppose we have a requirement to modify the default home page of Nginx to the following:

Custom Website from my containerThis is Jerry's custom website.

This website is served from my SAP Docker container.

Here are the detailed methods.

Command line-v mounts the host directory nginx-html into the / usr/share/nginx/html directory within the Nginx container.

Docker run-d-p 1081 name jerry-custom nginx 80-v `pwd` / nginx-html:/usr/share/nginx/html-- name jerry-custom nginx

Use vi to modify the index.html under the host directory nginx-html to custom content:

Enter the docker container interactively:

Docker exec-it jerry-custom / bin/sh

It is found that the index.html in the Docker container is also automatically modified, and the content is the same as that under the host directory nginx-html.

Localhost:1081 can see the modified custom Nginx home page:

Thank you for your reading, the above is "how to use Docker volume to modify index.html in Nginx Docker image", after the study of this article, I believe you have a deeper understanding of how to use Docker volume to modify index.html in Nginx Docker image, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report