Docker’s layered file system

1 Hierarchical file system

UnionFS union file system

  • bootfs:boot file system
  • rootfs:root file system
    Insert image description here

Hierarchical file system

Insert image description here

Insert image description here
Insert image description here

Insert image description here

  • Docker images are read-only. When the container is started, a new writable layer is added to the top of the image. This layer is what we usually call the container layer. Everything below the container layer is called the image layer.

Insert image description here

2 commit commit image

docker commit # 提交容器成为一个新的副本
docker commit -m="提交的描述信息" -a="作者" 容器id 目标镜像名:[TAG]
  • Create new image
➜  ~ docker commit -a="zhangxiaoyude" -m="add webapps app" 7b8096067457 tomcat02:1.0
sha256:6e0e1ad86723c435bdf26d368472195b7050de1d6b920252d9c93eac26132336
➜  ~ docker images                                                                  
REPOSITORY                                                TAG                                                                          IMAGE ID       CREATED          SIZE
tomcat02                                                  1.0                                                                          6e0e1ad86723   20 seconds ago   478MB
  • Check out the new image. I found that the new version is larger than the previous one because our changes are recorded in it.
    Insert image description here

Although using the docker commit command can help intuitively understand the concept of image tiered storage, it is not used this way in the actual environment.
First of all, if you carefully observe the results of the previous docker diff webserver, you will find that in addition to the /usr/share/nginx/html/index.html file that you really want to modify, many files have been changed or added due to the execution of the command. . This is just the simplest operation. If you install software packages, compile and build, a lot of irrelevant content will be added. If you don't clean it carefully, it will cause the image to be extremely bloated.
In addition, using docker commit means that all operations on the image are black box operations, and the generated image is also called a black box image. In other words, except for the person who made the image who knows what commands were executed and how to generate the image, no one else can No way of knowing. Moreover, even the person who made the image cannot remember exactly what he was doing after a while. Although docker diff may be able to tell you some clues, it is far from the point where you can ensure that a consistent image is generated. The maintenance of this black box image is very painful.

Guess you like

Origin blog.csdn.net/DeepLearning_/article/details/132713884