In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
About several main concepts in Docker
Here is an inappropriate analogy to illustrate.
You must have installed the ghost system, the image is like a ghost file, and the container is like a ghost system. You can install the system with someone else's ghost file (using an image to run the container), or you can make your own existing system into a ghost file (build an image from the container). Dockerfile is like a script (image build script) that generates ghost files, which specifies where to download which version of the window system, where to download which software to install, which configuration files to modify, and so on. This article focuses on how to build an image from a container (making an existing system into a ghost file) and how to build an image using Dockerfile (using a script to generate a ghost file).
The main steps of building an image in two ways:
1. Build an image from the container (hereinafter referred to as the container image)
Create a container, such as using a tomcat:latest image to create a tomcat-test container
Modify the file system of the tomcat-test container, such as the default port in the server.xml file of tomcat
Use the commit command to submit a mirror
2. Use Dockerfile to build an image (hereinafter referred to as Dockerfile image)
Write Dockerfile files
Use the build command to build an image
The difference between the two ways of building:
1. The builder of the container image can modify the container's file system and publish it at will. This modification is opaque to the image user, and the image builder generally will not record every step of the container file system in the document for reference by the image user.
2. A container image cannot (more accurately, is not recommended) be modified to generate a new container image.
Running the container from the image actually adds a writable layer on the top of the image. All modifications to the container file system are made in this layer and do not affect the existing layer. For example, if a 1G file is deleted in the container, from the user's point of view, the file is no longer in the container, but from the file system point of view, the file is still there, but it is marked at the top level that the file has been deleted. Of course, the file marked as deleted will also take up image space. To build an image from a container is to actually solidify the top layer of the container into the image.
In other words, after modifying the container image, a new container image will be generated, which will be one more layer, and the volume will only increase, not decrease. In the long run, the mirror will become more and more bloated. The export and import commands provided by Docker can deal with this problem to some extent, but they are not without drawbacks.
3. When the parent image on which the container image depends changes, the container image must be reconstructed. If you do not write an automated build script, but build it manually, it is worthless to re-modify the container's file system and then build it.
4. The Dockerfile image is completely transparent, and all instructions for building the image can be seen through Dockerfile. You can even recursively find the build instructions for any parent image of this image. In other words, you can fully understand how an image is built from scratch with one instruction after another.
5. When the Dockerfile image needs to be modified, it can be rebuilt and generated by modifying the instructions in Dockerfile without any problem.
6. Dockerfile can be hosted on source management sites such as GitHub, and DockerHub is automatically associated with the source code to build. When your Dockerfile changes, or the dependent parent image changes, it triggers the automatic construction of the image, which is very convenient.
Both officially and personally, it is recommended to use the second way to build an image.
The detailed instructions in Dockerfile are not listed here one by one. You can refer to the official documents or follow my subsequent articles. Of course, there is also a lot of search on the Internet.
The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.
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.