Home Operation and Maintenance Docker What is the earliest storage engine supported by docker?

What is the earliest storage engine supported by docker?

May 12, 2022 pm 03:27 PM
docker

AUFS is the earliest storage engine supported by docker. AUFS is a Union File System, which is a file-level storage driver. It was the storage driver used in the early days of Docker. It was recommended before Docker version 18.06 and Ubuntu version 14.04. It supports xfs and ext4 files.

What is the earliest storage engine supported by docker?

The operating environment of this tutorial: linux7.3 system, docker version 20, Dell G3 computer.

AUFS is the earliest storage engine supported by docker.

Docker’s storage engine

Docker’s storage engine is designed like this, but for different file systems, it is composed of different Storage driver to achieve. Next let’s talk about Docker’s storage driver.

Docker mainly has the following types of storage drivers:

  • overlay2: It is the recommended storage driver for the current version and can achieve excellent performance without additional dependencies and configurations. . Replaced the overlay storage driver after version 18.09. Support xfs, ext4 file system.

  • aufs: The earliest storage driver used by Docker, which is recommended before Docker 18.06 version and Ubuntu 14.04 version. Support xfs, ext4 file system.

  • devicemapper: It is the recommended storage driver for earlier versions of CentOS and RHEL systems, because they do not support overlay2 and require direct-lvm support.

  • btrfs: For btrfs file systems only.

  • zfs: Only for zfs file systems.

  • vfs: Does not depend on the file system, but the performance is extremely poor, mainly used for testing.

It should be noted that the overlay2, overlay, and aufs layers are based on files. When the write concurrency of a single file is high, large memory support is required, and the read and write layers may be A single file becomes very large. The layers of devicemapper, btrfs, and zfs are based on block storage, so they have little impact on the high concurrency of a single file. But btrfs and zfs are very memory intensive.

docker AUFS

AUFS is a Union File System. The so-called UnionFS is to merge and mount directories in different physical locations into the same directory. . One of the most important applications of UnionFS is to jointly mount a CD/DVD and a hard disk directory. Then, you can modify the files on this read-only CD/DVD (of course, the modified files are stored in in a directory on the hard drive).

AUFS was also called Another UnionFS, and later it was called Alternative UnionFS. Later, it may not be domineering enough, so it was called Advance UnionFS. Developed by Junjiro Okajima in 2006, AUFS completely rewrote the early UnionFS 1.x. Its main purpose was for reliability and performance, and it introduced some new features, such as writable branches. Load balancing. AUFS is fully compatible with UnionFS in use, and is much better in stability and performance than the previous UnionFS. Later, UnionFS 2.x began to copy the functions of AUFS. But he actually didn't get into the Linux trunk because Linus wouldn't let him. Basically, it was because the amount of code was relatively large and it was poorly written (compared to only 3,000 lines of union mount and 10,000 lines of UnionFS, and others, which averaged only 6,000 VFS has about 30,000 lines of code, and AUFS actually has 30,000 lines of code). Therefore, Okajima continued to improve the code quality, kept submitting, and was constantly rejected by Linus. Therefore, to this day, AUFS cannot enter the Linux trunk (today you can see The code to AUFS is actually pretty good, N times better than OpenSSL. Either Linus has very high requirements for code quality, or Linus just doesn't like AUFS).

However, fortunately, many distributions use AUFS, such as: Ubuntu 10.04, Debian6.0, Gentoo Live CD supports AUFS, so it is OK.

Okay, after all this gossip, let’s look at an example (environment: Ubuntu 14.04)

First, we create two directories (fruits and vegetables), and in these two Put some files in a directory. The fruits include apples and tomatoes, and the vegetables include carrots and tomatoes.

$ tree
.
├── fruits
│   ├── apple
│   └── tomato
└── vegetables
    ├── carrots
    └── tomato
Copy after login

Then, we enter the following command:

# 创建一个mount目录
$ mkdir mnt

# 把水果目录和蔬菜目录union mount到 ./mnt目录中
$ sudo mount -t aufs -o dirs=./fruits:./vegetables none ./mnt

#  查看./mnt目录
$ tree ./mnt
./mnt
├── apple
├── carrots
└── tomato
Copy after login

We can see that there are three files in the ./mnt directory, apple, carrots and tomatoes. The fruit and vegetable directories are unioned into the ./mnt directory.

Let’s modify the content of the file:

$ echo mnt > ./mnt/apple
$ cat ./mnt/apple
mnt
$ cat ./fruits/apple
mnt
Copy after login

In the above example, we can see that the content of ./mnt/apple has been changed, and the content of ./fruits/apple has also been changed. .

$ echo mnt_carrots > ./mnt/carrots
$ cat ./vegetables/carrots 

$ cat ./fruits/carrots
mnt_carrots
Copy after login

In the above example, we can see that we modified the file content of ./mnt/carrots, but ./vegetables/carrots did not change. Instead, carrots appeared in the directory ./fruits/carrots. file, its content is what we have in ./mnt/carrots.

In other words, in the mount aufs command, we did not refer to the directory permissions of vegetables and fruits. By default, the first (leftmost) directory on the command line is readable and writable. , everything after is read-only. (Generally speaking, the first directory should be writable, and the following directories should be read-only)

So, if we specify permissions to mount aufs as follows, you will find that there is no The same effect (remember to delete the above ./fruits/carrots file first):

$ sudo mount -t aufs -o dirs=./fruits=rw:./vegetables=rw none ./mnt

$ echo "mnt_carrots" > ./mnt/carrots 

$ cat ./vegetables/carrots
mnt_carrots

$ cat ./fruits/carrots
cat: ./fruits/carrots: No such file or directory
Copy after login

现在,在这情况下,如果我们要修改./mnt/tomato这个文件,那么究竟是哪个文件会被改写?

$ echo "mnt_tomato" > ./mnt/tomato 

$ cat ./fruits/tomato
mnt_tomato

$ cat ./vegetables/tomato
I am a vegetable
Copy after login

可见,如果有重复的文件名,在mount命令行上,越往前的就优先级越高。

你可以用这个例子做一些各种各样的试验,我这里主要是给大家一个感性认识,就不展开试验下去了。

那么,这种UnionFS有什么用?

历史上,有一个叫Knoppix的Linux发行版,其主要用于Linux演示、光盘教学、系统急救,以及商业产品的演示,不需要硬盘安装,直接把CD/DVD上的image运行在一个可写的存储设备上(比如一个U盘上),其实,也就是把CD/DVD这个文件系统和USB这个可写的系统给联合mount起来,这样你对CD/DVD上的image做的任何改动都会在被应用在U盘上,于是乎,你可以对CD/DVD上的内容进行任意的修改,因为改动都在U盘上,所以你改不坏原来的东西。

我们可以再发挥一下想像力,你也可以把一个目录,比如你的源代码,作为一个只读的template,和另一个你的working directory给union在一起,然后你就可以做各种修改而不用害怕会把源代码改坏了。有点像一个ad hoc snapshot。

Docker把UnionFS的想像力发挥到了容器的镜像。你是否还记得我在介绍Linux Namespace上篇中用mount namespace和chroot山寨了一镜像。现在当你看过了这个UnionFS的技术后,你是不是就明白了,你完全可以用UnionFS这样的技术做出分层的镜像来。

下图来自Docker的官方文档Layer,其很好的展示了Docker用UnionFS搭建的分层镜像。

What is the earliest storage engine supported by docker?

关于docker的分层镜像,除了aufs,docker还支持btrfs, devicemapper和vfs,你可以使用 -s 或 storage-driver= 选项来指定相关的镜像存储。在Ubuntu 14.04下,docker默认Ubuntu的 aufs(在CentOS7下,用的是devicemapper,关于devicemapper,我会以以后的文章中讲解)你可以在下面的目录中查看相关的每个层的镜像:

/var/lib/docker/aufs/diff/<id>
Copy after login

AUFS的一些特性

AUFS有所有Union FS的特性,把多个目录,合并成同一个目录,并可以为每个需要合并的目录指定相应的权限,实时的添加、删除、修改已经被mount好的目录。而且,他还能在多个可写的branch/dir间进行负载均衡。

上面的例子,我们已经看到AUFS的mount的示例了。下面我们来看一看被union的目录(分支)的相关权限:

  • rw表示可写可读read-write。

  • ro表示read-only,如果你不指权限,那么除了第一个外ro是默认值,对于ro分支,其永远不会收到写操作,也不会收到查找whiteout的操作。

  • rr表示real-read-only,与read-only不同的是,rr标记的是天生就是只读的分支,这样,AUFS可以提高性能,比如不再设置inotify来检查文件变动通知。

推荐学习:《docker视频教程

The above is the detailed content of What is the earliest storage engine supported by docker?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to update the image of docker How to update the image of docker Apr 15, 2025 pm 12:03 PM

The steps to update a Docker image are as follows: Pull the latest image tag New image Delete the old image for a specific tag (optional) Restart the container (if needed)

How to use docker desktop How to use docker desktop Apr 15, 2025 am 11:45 AM

How to use Docker Desktop? Docker Desktop is a tool for running Docker containers on local machines. The steps to use include: 1. Install Docker Desktop; 2. Start Docker Desktop; 3. Create Docker image (using Dockerfile); 4. Build Docker image (using docker build); 5. Run Docker container (using docker run).

How to exit the container by docker How to exit the container by docker Apr 15, 2025 pm 12:15 PM

Four ways to exit Docker container: Use Ctrl D in the container terminal Enter exit command in the container terminal Use docker stop &lt;container_name&gt; Command Use docker kill &lt;container_name&gt; command in the host terminal (force exit)

How to copy files in docker to outside How to copy files in docker to outside Apr 15, 2025 pm 12:12 PM

Methods for copying files to external hosts in Docker: Use the docker cp command: Execute docker cp [Options] &lt;Container Path&gt; &lt;Host Path&gt;. Using data volumes: Create a directory on the host, and use the -v parameter to mount the directory into the container when creating the container to achieve bidirectional file synchronization.

How to view the docker process How to view the docker process Apr 15, 2025 am 11:48 AM

Docker process viewing method: 1. Docker CLI command: docker ps; 2. Systemd CLI command: systemctl status docker; 3. Docker Compose CLI command: docker-compose ps; 4. Process Explorer (Windows); 5. /proc directory (Linux).

How to check the name of the docker container How to check the name of the docker container Apr 15, 2025 pm 12:21 PM

You can query the Docker container name by following the steps: List all containers (docker ps). Filter the container list (using the grep command). Gets the container name (located in the "NAMES" column).

How to save docker image How to save docker image Apr 15, 2025 am 11:54 AM

To save the image in Docker, you can use the docker commit command to create a new image, containing the current state of the specified container, syntax: docker commit [Options] Container ID Image name. To save the image to the repository, you can use the docker push command, syntax: docker push image name [: tag]. To import saved images, you can use the docker pull command, syntax: docker pull image name [: tag].

How to start mysql by docker How to start mysql by docker Apr 15, 2025 pm 12:09 PM

The process of starting MySQL in Docker consists of the following steps: Pull the MySQL image to create and start the container, set the root user password, and map the port verification connection Create the database and the user grants all permissions to the database

See all articles