摘录几篇比较好的参考文档:

1.Docker 联合文件系统(Union Filesystem): https://www.jianshu.com/p/5ec3d4dbf580

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

2.Visualizing Docker Containers and Images: http://merrigrove.blogspot.com/2015/10/visualizing-docker-containers-and-images.html

3.About storage drivers: https://docs.docker.com/storage/storagedriver/

摘录自参考文档一

假设Dockerfile 内容如下
FROM ubuntu:14.04
ADD run.sh /
VOLUME /data
CMD ["./run.sh"]
联合文件系统对应的层次结构如下图所示

Docker联合文件系统 随笔 第1张

摘录自参考文档二

Docker联合文件系统 随笔 第2张

镜像(Images):

The first visual I present is that of an image, shown below with two different visuals.  It is defined as the "union view" of a stack of read-only layers.

Docker联合文件系统 随笔 第3张

 

一层一层的只读层,代表本层和下面层的diff,若本层有文件系统的改动,则Read Layer包含具体改动后的文件,若没有文件系统的改动(比如仅仅只是增加了环境变量等),会记录到Meta Json中。

镜像层是存储在主机文件系统中的,针对aufs这种类型的文件系统驱动,可以去查看/var/lib/docker/aufs下的目录结构

sudo tree -L 1 /var/lib/docker/ /var/lib/docker/ ├── aufs ├── containers ├── graph ├── init ├── linkgraph.db ├── repositories-aufs ├── tmp ├── trust └── volumes Finally, to tie up some loose ends, we should define an image layer. The below image shows an image layer and makes us realize that a layer is not just the changes to the file system. Docker联合文件系统 随笔 第4张   The metadata is additional information about the layer that allows docker to capture runtime and build-time information, but also hierarchical information on a layer's parent. Both read and read-write layers contain this metadata. Docker联合文件系统 随笔 第5张

 

 容器(Container):

A container is defined as a "union view" of a stack of layers the top of which is a read-write layer.

Docker联合文件系统 随笔 第6张

运行中的容器(Running Container):

 A running container is defined as a read-write "union view" and the the isolated process-space and processes within.  The below visual shows the read-write container surrounded by this process-space.

Docker联合文件系统 随笔 第7张

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄