UnionFS
(United File System) is a layered, lightweight and high-performance file system that supports the
The file system modification is used as a submission to overlay layer by layer, and different directories can be mounted to the same virtual
Under the file system.
UnionFS
It is a kind of
Linux
,
FreeBSD
and
NetBSD
Operating system design
It combines file system services to a joint mount point. It uses
branch
Put different file systems
Files and Directories
“
Transparently
”
Overwrite to form a single consistent file system. These
branches
Or
read-only
Or
read-write
, so when writing to this virtual joint file system
The system has actually written a new file. It seems that the virtual joint file system is OK
Any file is operated on, but it does not change the original file, because
unionfs
Used one
An important asset management technology is called copying on writing.
Copy on writing (
copy-on-write
, the abbreviation below
CoW
), also known as implicit sharing, is a kind of modification
Resource management technology for efficient replication of sources. Its idea is that if a resource is duplicate, but nothing
To modify, there is no need to create a new resource immediately; this resource can be shared by old and new instances. create
The new resource occurs when the first write operation is made, that is, when the resource is modified. Through this resource sharing
The consumption caused by unmodified resource replication can be significantly reduced.
However, it will also be added when revising resources
Add a small amount of overhead.
See againDocker What is a mirror
image
There are layers of file systems inside
Union FS
. Federation file system, several layers of directories can be mounted to
Together, form a virtual file system. The directory structure of the virtual file system is like a normal one
linux
Directory structure one
Sample,
docker
These files and the host's kernel provide a
linux
virtual environment.
We call each layer of file system one layer
layer
, the joint file system can set three files for each layer of file system.
type of permission, read-only (
readonly
), read and write (
readwrite
) and write (
whiteout-able
),but
docker
Each layer of the file system in the image is read-only.
When building a mirror, starting with the most basic operating system, each build operation is equivalent to doing one layer.
The modification has added a layer of file system. The layer is superimposed upwards, and the modification of the upper layer will cover the position of the bottom layer.
Seeing the nature is also easy to understand, just like the upper layer blocking the bottom layer. When you use it, you will only see
A complete whole, you don’t know how many layers there are, nor do you know what the modifications made in each layer are.
You can see that the mirror hierarchical structure has the following characteristics
(1) Mirror shared host
kernel
(2)
base
The mirror is
linux
Minimum release of
(3) Same
docker
The host supports different
Linux
Release
(4) Adopt a hierarchical structure, the upper layer can refer to the lower layer to maximize the shared resources
(5) The container layer is located in the writable layer, using
cow
The technology is modified, and this layer only maintains the changing part, and does not
Modify the part below the image
(6) Below the container layer are read-only layers
(7)
docker
Find files from top to bottom
The principle of mirror implementation
Docker
The principle of layered storage implementation
1. Implementation of hierarchical storage
docker
The basis of mirroring technology is the joint file system
(UnionFS), whose file system is hierarchical Linux
Implemented by each distribution
UnionFS
Different, so
docker
In different
Used in linux distributionsIt's also different. The docker info command can be used to view which UnionFS is used in the current system, and several common ones
The distribution is used as follows: