Docker-Core (3)-Docker container image

1. UnionFS

  1. UnionFS (Union File System) is a layered, lightweight and high-performance file system
  2. It supports the modification of the file system as a submission to superimpose layer by layer, and can mount different directories into the same virtual file system (unite several directories into a single virtual filesystem)
  3. The Union filesystem is the basis of Docker images
  4. Images can be inherited by layering. Based on the base image (no parent image), various specific application images can be made
  5. Features: Load multiple file systems at the same time, but from the outside, only one file system can be seen. Joint loading will superimpose the file systems of each layer, so that the final file system will contain all underlying files and directories

2. Image loading

  1. The bootfs file system will be loaded when Linux is first started, and the bottom layer of the Docker image is bootfs
  2. This layer is the same as a typical Linux/Unix system, including the boot loader and kernel
  3. When the boot loading is complete, the entire kernel is in the memory. At this time, the right to use the memory has been transferred from the bootfs to the kernel. At this time, the system will also unload the bootfs.
  4. rootfs (root file system), on top of bootfs, contains standard directories and files such as /dev, /proc, /bin, /etc in a typical Linux system
  5. Rootfs is a variety of different operating system distributions, such as Ubuntu, Centos and so on.

image.png

  1. For a streamlined OS, the rootfs can be very small and only needs to include the most basic commands, tools, and program libraries. Because the underlying layer directly uses the Host's kernel, you only need to provide the rootfs.
  2. It can be seen that for different linux distributions, the bootfs is basically the same, and the rootfs will be different, so different distributions can share the bootfs

3. Mirror layering

  1. Layered mirroring, pull as an example, during the download process, you can see that the docker mirroring seems to be downloading layer by layer
[root@localhost data]# docker pull mongo
Using default tag: latest
latest: Pulling from library/mongo
# 分层下载
16ec32c2132b: Pull complete 
6335cf672677: Pull complete 
cbc70ccc8ebe: Pull complete 
0d1a3c6bd417: Pull complete 
960f3b9b27d3: Pull complete 
aff995a136b4: Pull complete 
4249be7550a8: Pull complete 
4da411c5a406: Pull complete 
4b9c6ac629be: Pull complete 
4de7437f497e: Pull complete
  1. When deleting, it is also deleted hierarchically
[root@localhost data]# docker rmi mongo
Untagged: mongo:latest
Untagged: mongo@sha256:d78c7ace6822297a7e1c7076eb9a7560a81a6ef856ab8d9cde5d18438ca9e8bf
Deleted: sha256:aad77ae58e0c58ad95794d3fe2df3ba770be6633cd4321bbf423d4555813c07d
Deleted: sha256:41e182e5c67aa08e53d812b79668911d800b0e3ad0d0cb479f7a224a6e17e508
Deleted: sha256:1cff9be1a40466843a85137c5b8152deafeadcdd2ab18df406ef00a5443cb27c
Deleted: sha256:0d32c2d86c0c5c91d8e692fde64ad3a8e0c63ae1591006fcf7b129614d6cc4bf
Deleted: sha256:b8e46b2ea0eae31ebff37961ebd82f0d472a9e11fc8155345b23c71633918dea
Deleted: sha256:53688fa39c466b3df351c4eae26211861928d908798cdc3a4a75bfb883a1f4eb
Deleted: sha256:370c705504bcd2dceaba4b1f81f016b2a107a0f28ac957abe63da87ba122ecf5
Deleted: sha256:7335732c3552eb5a327184e4547a4e98acd664ebd5d2a1d3a5c2c9407fdf5762
Deleted: sha256:f569a6f2fe9c65ec15b9baa09ab312fd72ea5a08c691713850cd32d147fe7515
Deleted: sha256:1a5eaac255fb0d198d7a10042a454a3d13b0cee0c036f925a00e0c715c352199
Deleted: sha256:7555a8182c42c7737a384cfe03a3c7329f646a3bf389c4bcd75379fc85e6c144
  1. One of the biggest benefits of adopting a hierarchical structure is the sharing of resources . The advantages are as follows
    • If multiple images are built from the same base image, the host only needs to save one base image on disk
    • At the same time, only one base image needs to be loaded in memory to serve all containers
    • And every layer of the image can be shared
  2. Docker images are all read-only. When the container starts, a new writable layer is loaded on top of the image. This layer is usually called the "container layer", and everything below the "container layer" is called the "mirror layer". , all operations are done based on containers rather than images

4. Mirror submission

  1. When we are running a container, we may need to modify something, and then we need to create a new image based on the latest image
  2. You can use docker commit to submit a copy of the container to make it a new image, and the new image will contain all the modified information
    • docker commit -m="commit description information" -a="author" container ID target image name to be created: [label name]
docker commit -m "重新生成容器" -a "TianXinCoord" <已有容器id>  codecoord:1.0

Five, virtual mirror

  1. The warehouse name and label are mirror images, commonly known as dangling image
  2. Make a profit by writing a Docker image, and then build without specifying any tag
from ubuntu
CMD echo 'action is success'
  1. run mirror
    • docker build . : no tag specified
  2. mirror view
docker image ls -f dangling=true
  1. The virtual mirror has lost its existence value and can be deleted
docker image prune
  1. It can also be deleted by using the docker rmi mirror id method, and all of the above can be deleted

Guess you like

Origin blog.csdn.net/sinat_34104446/article/details/125014490