Docker联合文件系统
摘录几篇比较好的参考文档:
1.Docker 联合文件系统(Union Filesystem): https://www.jianshu.com/p/5ec3d4dbf580
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"]
联合文件系统对应的层次结构如下图所示
摘录自参考文档二:
镜像(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.
一层一层的只读层,代表本层和下面层的diff,若本层有文件系统的改动,则Read Layer包含具体改动后的文件,若没有文件系统的改动(比如仅仅只是增加了环境变量等),会记录到Meta Json中。
镜像层是存储在主机文件系统中的,针对aufs这种类型的文件系统驱动,可以去查看/var/lib/docker/aufs下的目录结构
容器(Container):
A container is defined as a "union view" of a stack of layers the top of which is a read-write layer.
运行中的容器(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.