[docker]存储驱动overlay和overlay2的区别

overlay和overlay2的区别

参考:http://blog.csdn.net/styshoo/article/details/60715942

docker pull ubuntu

本质区别是镜像层之间共享数据的方法不同

overlay共享数据方式是通过硬连接
而overlay2是通过每层的 lower文件

root@no1:/var/lib/docker/overlay2# ll
total 32K
drwx------ 3 root root 4.0K 2017-12-13 22:03:57.063074124 -0800 a6350774f0c5a4c89f850252180930a48ae28ca37c33ac3a2ba39585bb3c2c42/
drwx------ 5 root root 4.0K 2017-12-13 22:04:00.471007047 -0800 43a794c7d4fc61414cceedb2914026f09c9228397a885fb2d040278d6a1b5856/
drwx------ 5 root root 4.0K 2017-12-13 22:04:00.511006259 -0800 33a4e0217cb0342f024ee2f093ab7188433b2b231c75999848bd2d36eb501255/
drwx------ 5 root root 4.0K 2017-12-13 22:04:00.539005708 -0800 b3db2d8f59e546b4978148f032e563157310b0455f6c6bab144f6ae6a279986d/
drwx------ 5 root root 4.0K 2017-12-13 22:04:00.567005157 -0800 e46f69d82b2b77d04b095279e173f4f51fb10c7b3a0c27fa688bb52b74fe0b7f/
drwx------ 2 root root 4.0K 2017-12-13 22:23:26.699634959 -0800 l/

查看第一层 第二层 第三层目录结构

root@no1:/var/lib/docker/overlay2# ll a6350774f0c5a4c89f850252180930a48ae28ca37c33ac3a2ba39585bb3c2c42/
total 8.0K
-rw-r--r--  1 root root   26 2017-12-13 22:03:57.063074124 -0800 link
drwxr-xr-x 21 root root 4.0K 2017-12-13 22:03:59.027035468 -0800 diff/ ##挂载点
root@no1:/var/lib/docker/overlay2# ll 43a794c7d4fc61414cceedb2914026f09c9228397a885fb2d040278d6a1b5856/
total 20K
drwx------ 2 root root 4.0K 2017-12-13 22:04:00.471007047 -0800 work/
drwx------ 2 root root 4.0K 2017-12-13 22:04:00.471007047 -0800 merged/
-rw-r--r-- 1 root root   28 2017-12-13 22:04:00.471007047 -0800 lower
-rw-r--r-- 1 root root   26 2017-12-13 22:04:00.471007047 -0800 link
drwxr-xr-x 6 root root 4.0K 2017-12-13 22:04:00.503006417 -0800 diff/

root@no1:/var/lib/docker/overlay2# ll 33a4e0217cb0342f024ee2f093ab7188433b2b231c75999848bd2d36eb501255/
total 20K
drwx------ 2 root root 4.0K 2017-12-13 22:04:00.511006259 -0800 work/
drwx------ 2 root root 4.0K 2017-12-13 22:04:00.511006259 -0800 merged/
-rw-r--r-- 1 root root   57 2017-12-13 22:04:00.511006259 -0800 lower
-rw-r--r-- 1 root root   26 2017-12-13 22:04:00.511006259 -0800 link
drwxr-xr-x 3 root root 4.0K 2017-12-13 22:04:00.531005866 -0800 diff/

在看看第二层和第三层的lower文件-逐递加

root@no1:/var/lib/docker/overlay2# 
root@no1:/var/lib/docker/overlay2# cat a6350774f0c5a4c89f850252180930a48ae28ca37c33ac3a2ba39585bb3c2c42/l^C
root@no1:/var/lib/docker/overlay2# cat 43a794c7d4fc61414cceedb2914026f09c9228397a885fb2d040278d6a1b5856/lower 
l/UZH33GFG3GMRJCYLAIHJQKEUIN
root@no1:/var/lib/docker/overlay2# cat 33a4e0217cb0342f024ee2f093ab7188433b2b231c75999848bd2d36eb501255/lower 
l/QQIYMV3GOYXUTDN6GAAKSM7ZFL:l/UZH33GFG3GMRJCYLAIHJQKEUIN

测试:
Ubuntu16安装的docker
9e792b8fgy1fmgam0rfvpj20kc087jrk.jpg
另一台是centos7上安装的docker

观察挂载

lowerdir
upperdir
workdir

查看挂载方式
mount|grep overlay

overlay: 只挂载一层,其他层通过最高层通过硬连接形式共享(增加了磁盘inode的负担)
/var/lib/docker/overlay/ae6ca8bdaf74720c26b4d780d0c7837e487505c410efb5b9d891bb78796e8e0f/merged type overlay
(rw,relatime,
lowerdir=/var/lib/docker/overlay/632707d3098b737da98ada134fb2cdb8c18c6492dabc9fabbc08e664afc23b8e/root,
upperdir=/var/lib/docker/overlay/ae6ca8bdaf74720c26b4d780d0c7837e487505c410efb5b9d891bb78796e8e0f/upper,
workdir=/var/lib/docker/overlay/ae6ca8bdaf74720c26b4d780d0c7837e487505c410efb5b9d891bb78796e8e0f/work)



overlay2: 逐层挂载
(rw,relatime,
lowerdir=/var/lib/docker/overlay2/l/AQLAUEDWASUZFK6WMTNMV67AEF:/var/lib/docker/overlay2/l/KWJWIYWDTPZCGVRASSRIVREKMN:/var/lib/docker/overlay2/l/ZYQCFR4K5ZI5GDFJXHINZJTNF2:/var/lib/docker/overlay2/l/EY6ZNSFU3IGYHG3ALKBRVDWMX2:/var/lib/docker/overlay2/l/QQIYMV3GOYXUTDN6GAAKSM7ZFL:/var/lib/docker/overlay2/l/UZH33GFG3GMRJCYLAIHJQKEUIN,
upperdir=/var/lib/docker/overlay2/2d3b5711d26366b06283c1e8632d5065b9b6ba2e027b7cdd351a2d89b3810dfd/diff,
workdir=/var/lib/docker/overlay2/2d3b5711d26366b06283c1e8632d5065b9b6ba2e027b7cdd351a2d89b3810dfd/work)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值