docker-core-tech-aufs
AUFS
Introduction
- advanced multi layered unification filesystemAufs is a stackable unification filesystem such as Union fs which unifies several directories and provides a merged single directory.
- overlay2 is the preferred storage driver, for all currently supported Linux distributions, and requires no extra configuration.
- aufs was the preferred storage driver for Docker 18.06 and older, when running on Ubuntu 14.04 on kernel 3.13 which had no support for overlay2
AUFS is not merged into linux main branch, only ubuntu/debian support it!!!
Core Concept
Here is an example to merge two dirs into a single one, let’s explain it in details.
1 | # mount -t aufs -o br=/tmp/dir1:/tmp/dir2 none /tmp/uniondir |
This is the basic usage for aufs, more options refer to
each dir is called branch, the dir has order, the first one call top branch(br0), the later called bottom branch(brX)
Order is important as
- if same file(with path) exists in different branches, the top branch wins
- Only top branch has RW attribute, others has RO if not set explicitly
AUFS create/modify/delete
check aufs is supported or not
1 | # grep aufs /proc/filesystems |
then mount two dirs into single one
1 | # mount -t aufs -o br=/tmp/dir1:/tmp/dir2 none /tmp/udir |
Create file
1 | # touch udir/file3 |
As you can see new file is created at RW branch
modify file
modify file from RW branch
1 | # echo 'f1' >>udir/file1 |
file is updated both in aufs and it’s source
modify file from RO branch
1 | # echo 'f2' >>udir/file2 |
file is coped to RW branch, the original one unchanged
Delete file
delete file from RW
File is deleted from disk as well
delete file from RO branch
1 | # tree -a . |
Note: actually file is hided, so that you can't see it from udir
as a whiteout file is created in the RW branch to tell aufs does not show the file which is deleted
check mount point and info
1 | /tmp/udir must exist before mount |