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

The second part of the introduction to Docker series: using dockerfile to create an image containing a specified web application

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

Share

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

In the previous article: one of the getting started series on Docker: running a specified web application in a Docker container

We have successfully deployed a web application we developed locally to run in a Docker container.

This article will show you how to make a Docker image that contains the web application.

After the image is made, any other user on the Internet can easily download and run your image.

Create a new folder jerry-build, put your web application in this folder, and my web application in the folder webapp. Create a new file dockerfile in the jerry-build folder:

This dockerfile is very simple, just three lines:

FROM nginx:stableCOPY webapp/ / usr/share/nginx/html/webapp/RUN ls-la / usr/share/nginx/html/webapp*

We carry out the order docker build.

This command successfully typed all the files in the webapp folder that contains our web application into the nginx image:

Use the option-t to specify the name of the generated image jerry-nginx-image:

After the image is generated successfully, you can use the docker run command to execute the image:

Docker run-d-p 1082 80 jerry-nginx-image:1.0

Using the command docker images, you can see the image we just made, the size is 109MB.

The next article in this series will show you how to publish this finished image to Docker hub.

For more original Jerry articles, please follow the official account "Wang Zixi":

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

*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