2019独角兽企业重金招聘Python工程师标准>>>
本文的目的是说明,如何在生产环境中选择Docker 的storage driver。以及对应Linux发行版本下Docker storage driver的配置方法。主要参考,docker docs中对于storage driver中的介绍及docker商用版本兼容性矩阵中linux发行版本对于存储驱动的说明。
当前docker支持的storage driver包括:aufs,brtfs,devicemap,OverlayFs,ZFS 5种存储驱动。参考:
https://docs.docker.com/engine/userguide/storagedriver/和
https://success.docker.com/Get_Help/Compatibility_Matrix_and_Maintenance_Lifecycle种的说明,当前生产环境中建议如下:
rhel,centos,fedora:devicemapper direct-lvm
ubuntu:aufs
suse:brtfs
当前,生产环境中不建议使用zfs及overlayfs。由于公司产品使用的是centos 7,因此本文介绍下cenos7中如何配置docker使用devicemapper direct-lvm。停止docker daemonsystemctl stop docker
1
1
删除/var/lib/docker,rm -rf /var/lib/docker
1
1
利用pvcreate命令在空闲块上创建物理卷pvcreate /dev/sdx
1
1
利用上一步中创建的pv创建卷组vgcreate vg-docker /dev/sdx
1
1
分别创建data,metadata逻辑卷组lvcreate -L 90G -n data vg-docker
lvcreate -L 10G -n metadata vg-docker
1
2
1
2
docker daemon参数配置--storage-driver=devicemapper --storage-opt dm.datadev=/dev/vg-docker/data --storage-opt dm.metadatadev=/dev/vg-docker/metadata
1
1
上述配置完成后,重启docker daemon即可完成配置。下面是配置完成后docker info查询的消息。[root@net1 docker]# docker info
Containers: 100Running: 0Paused: 0Stopped: 100
Images: 2
Server Version: 1.10.3
Storage Driver: devicemapperPool Name: docker-253:0-469034-poolPool Blocksize: 65.54 kBBase Device Size: 10.74 GBBacking Filesystem: xfsData file: /dev/vg-docker/dataMetadata file: /dev/vg-docker/metadataData Space Used: 799.4 MBData Space Total: 10.74 GBData Space Available: 9.938 GBMetadata Space Used: 1.729 MBMetadata Space Total: 10.63 GBMetadata Space Available: 10.63 GBUdev Sync Supported: trueDeferred Removal Enabled: falseDeferred Deletion Enabled: falseDeferred Deleted Device Count: 0Library Version: 1.02.107-RHEL7 (2015-12-01)
Execution Driver: native-0.2
Logging Driver: json-file
Plugins: Volume: localNetwork: null host overlay bridge
Kernel Version: 3.10.0-229.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 993.6 MiB
Name: net1
ID: TU6M:E6WM:PZDN:ULJX:EWKS:UPLQ:Z54D:XP52:64C7:Z4XN:TJ76:VG7O
WARNING: bridge-nf-call-ip6tables is disabled
Cluster store: etcd://172.28.0.2:4001
Cluster advertise: 172.28.0.3:0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
总结
参考docker的介绍,centos7推荐使用devicemapper。同时,从docker官方文档的介绍可以看到无论使用哪种storage driver均推荐挂载数据卷。后续,会继续分析docker 当前多余数据卷的管理方法。
http://blog.csdn.net/asd05txffh/article/details/51134995