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 run a specified web application in a Docker container

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

Share

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

This article mainly introduces "how to run a specified web application in a Docker container". In the daily operation, I believe that many people have doubts about how to run the specified web application in a Docker container. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the questions of "how to run the specified web application in a Docker container". Next, please follow the editor to study!

First use the command docker ps to ensure that there are no currently running Docker instances.

Run the command docker run-it nginx:

Then we open another terminal and use the docker ps command to view the running container instance. Status's Up 54 seconds means that 54 seconds have passed since the instance was started.

Use the command to enter the container instance:

Docker exec-it bbc5d48a761c / bin/sh

After entering, we see the shell prompt #, and we can execute some common commands in the nginx container.

/ usr/share/nginx/html is the location in the nginx server where web applications are stored, and now we just have to find a way to put our web applications in this folder.

I have provided a sample web application that can be obtained from my github:

Https://github.com/i042416/jerrylist/tree/master/webapp

The problem is how to get the web application to the corresponding folder in the container.

I use docker volume to realize the data sharing between docker and host. Use docker stop to stop the original docker instance, and then start a new one.

Suppose I download the webapp folder in the github I provided to the ~ directory, and then connect the webapp folder to the folder with the same name in the nginx container with the following command line:

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

At this point, the study on "how to run a specified web application in a Docker container" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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: 283

*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