In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to adjust the size of Image in Docker, which has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let's take a look at it.
The most direct benefit of Docker to developers is that they can package their applications, bundle all applications in an envelope, and then publish them to any popular Linux machine. Moreover, Docker can be virtualized and does not need any interface between various applications. In other words, we often say that "out of the box", there is no need to install or configure a large number of related software, hardware and so on.
And Docker Image is the Docker image. The Docker image is a read-only template. For example, an image can contain a Ubuntu system, an Apache Web server installed on Ubuntu, and your own applications. Mirrors are used to create containers. Docker provides an easy way to create new images or update existing ones, and you can even download images provided elsewhere.
Because Docker uses a unified file system, a Docker image is actually a collection of files, not an operating system like VM. The image can be as simple as a program file. For example, if you write a simple hello world program and put it in an empty image, the size of the entire image is the size of your compiled binary file.
It's good to have a small Docker Image, so you don't have to waste your own SSD space to deal with billions of bytes of Docker data.
Sometimes, due to the large-scale development of enterprise business, Docker Image becomes very large. Technical developers have to find a way to resize Image. How to continuously optimize the application and finally reduce the Image size to half of its original size?
The first step is Image layering. Use Ubuntu as the basic image to build a Java running environment. If you have related applications, you also need to integrate third-party results checking tools. For example: install Mono, install TSLint and ESLint through NPM, so that we can get more image processing power.
The second step is to check BUG. Previously, the size of Image was the size of 1GB. However, in a regular pull, the technician wants to download the same amount of data as the source data, because the basic Image (Ubuntu, Java, …) And keep it stable. But my console shows something different:
It seems that some data has been downloaded many times. Because this is the last layer, these are all real distribution files. After checking the Dockerfile, it is found that all directories have been edited. In traditional deployment settings, the safe way to operate is that Docker must add a new mirror layer and contain all distribution files and ownership information.
Before the actual Docker is built, it is easy to get rid of the chown call by adjusting the ownership information, thus saving 300MB in the final Image.
The third step is to continue to delete bytes. The size of the file is 670 MB, which is just the beginning, and there is still some room for deletion. When OpenJDK is used for Java runs, it comes with a number of development and GUI tools. Replacing useless OpenJRE can immediately save nearly 100 MB of memory. Then run StyleCop and read the information from the .NET PDB file in Mono. Mono has been installed in the mono-complete package to achieve more megabytes deletion through strong dependencies, such as a full MonoDevelop. Both ESLint and TSLint can only be started when NodeJS is running.
Finally, we added all the applications to Docker Image separately, and the image size was reduced from 1GB to 480MB.
Thank you for reading this article carefully. I hope the article "how to adjust the size of Image in Docker" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.