UnionFS (Union File System) is a layered, lightweight and high-performance file system
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)
The Union filesystem is the basis of Docker images
Images can be inherited by layering. Based on the base image (no parent image), various specific application images can be made
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
The bootfs file system will be loaded when Linux is first started, and the bottom layer of the Docker image is bootfs
This layer is the same as a typical Linux/Unix system, including the boot loader and kernel
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.
rootfs (root file system), on top of bootfs, contains standard directories and files such as /dev, /proc, /bin, /etc in a typical Linux system
Rootfs is a variety of different operating system distributions, such as Ubuntu, Centos and so on.
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.
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
Layered mirroring, pull as an example, during the download process, you can see that the docker mirroring seems to be downloading layer by layer
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
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
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
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
The warehouse name and label are mirror images, commonly known as dangling image
Make a profit by writing a Docker image, and then build without specifying any tag
from ubuntu
CMD echo 'action is success'
run mirror
docker build . : no tag specified
mirror view
docker image ls -f dangling=true
The virtual mirror has lost its existence value and can be deleted
docker image prune
It can also be deleted by using the docker rmi mirror id method, and all of the above can be deleted