In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you the implementation of Docker multi-stage image construction, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!
Since the Docker version of 17.05.0-ce, a new way to build images has been supported, called Multi-stage builds, which is designed to address some of the pain points in Docker building application containers. In the daily scenario of building a container, it is often encountered that the source code is obtained, compiled and generated in the same container, and finally built as an image. The disadvantage of doing so is:
Have to install the runtime environment necessary for the builder in the container
Have to get the source code of the program and some ecological tools needed to build in the same container
The constructed image even contains the program source code and some unnecessary files, resulting in the large size of the container image.
Of course, there is also a slightly more elegant way, that is, we package the project and its dependent library compilation tests externally in advance, and then copy them into the build directory, although this can well avoid the risk points that exist in the first way. However, you also need to consider the differences in the compatibility of different mirror runs.
In fact, these pain points, Docker also thought of, the official provides a simple multi-stage build (multi-stage build) solution. The so-called multi-stage construction, that is, the construction process is divided into multiple stages, in the same Dockerfile, through different stages to build and generate the required application files, and finally add these application files to a release image. Doing so can completely avoid a series of problems encountered above. Implementing a multi-stage build mainly depends on the newly provided keywords: from and as.
Here's a chestnut:
The benefits of multi-stage construction are self-evident. You can easily build the desired container image through a single Dockerfile for multiple projects that depend on each other, without having to worry about risks such as too large image and source code disclosure. I have to say, this is a very good improvement.
These are all the contents of the article "implementation of Docker Multi-stage Image Construction". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Original link: https://xiaozhou.net/docker-multi-stage-builds-2018-08-20.html
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.