github.com/adxhyt/docker@v1.4.2-0.20150117221845-467b7c821390/daemon/graphdriver/devmapper/README.md (about) 1 ## devicemapper - a storage backend based on Device Mapper 2 3 ### Theory of operation 4 5 The device mapper graphdriver uses the device mapper thin provisioning 6 module (dm-thinp) to implement CoW snapshots. For each devicemapper 7 graph location (typically `/var/lib/docker/devicemapper`, $graph below) 8 a thin pool is created based on two block devices, one for data and 9 one for metadata. By default these block devices are created 10 automatically by using loopback mounts of automatically created sparse 11 files. 12 13 The default loopback files used are `$graph/devicemapper/data` and 14 `$graph/devicemapper/metadata`. Additional metadata required to map 15 from docker entities to the corresponding devicemapper volumes is 16 stored in the `$graph/devicemapper/json` file (encoded as Json). 17 18 In order to support multiple devicemapper graphs on a system, the thin 19 pool will be named something like: `docker-0:33-19478248-pool`, where 20 the `0:33` part is the minor/major device nr and `19478248` is the 21 inode number of the $graph directory. 22 23 On the thin pool, docker automatically creates a base thin device, 24 called something like `docker-0:33-19478248-base` of a fixed 25 size. This is automatically formatted with an empty filesystem on 26 creation. This device is the base of all docker images and 27 containers. All base images are snapshots of this device and those 28 images are then in turn used as snapshots for other images and 29 eventually containers. 30 31 ### options 32 33 The devicemapper backend supports some options that you can specify 34 when starting the docker daemon using the `--storage-opt` flags. 35 This uses the `dm` prefix and would be used something like `docker -d --storage-opt dm.foo=bar`. 36 37 Here is the list of supported options: 38 39 * `dm.basesize` 40 41 Specifies the size to use when creating the base device, which 42 limits the size of images and containers. The default value is 43 10G. Note, thin devices are inherently "sparse", so a 10G device 44 which is mostly empty doesn't use 10 GB of space on the 45 pool. However, the filesystem will use more space for the empty 46 case the larger the device is. **Warning**: This value affects the 47 system-wide "base" empty filesystem that may already be 48 initialized and inherited by pulled images. Typically, a change 49 to this value will require additional steps to take effect: 1) 50 stop `docker -d`, 2) `rm -rf /var/lib/docker`, 3) start `docker -d`. 51 52 Example use: 53 54 ``docker -d --storage-opt dm.basesize=20G`` 55 56 * `dm.loopdatasize` 57 58 Specifies the size to use when creating the loopback file for the 59 "data" device which is used for the thin pool. The default size is 60 100G. Note that the file is sparse, so it will not initially take 61 up this much space. 62 63 Example use: 64 65 ``docker -d --storage-opt dm.loopdatasize=200G`` 66 67 * `dm.loopmetadatasize` 68 69 Specifies the size to use when creating the loopback file for the 70 "metadadata" device which is used for the thin pool. The default size is 71 2G. Note that the file is sparse, so it will not initially take 72 up this much space. 73 74 Example use: 75 76 ``docker -d --storage-opt dm.loopmetadatasize=4G`` 77 78 * `dm.fs` 79 80 Specifies the filesystem type to use for the base device. The supported 81 options are "ext4" and "xfs". The default is "ext4" 82 83 Example use: 84 85 ``docker -d --storage-opt dm.fs=xfs`` 86 87 * `dm.mkfsarg` 88 89 Specifies extra mkfs arguments to be used when creating the base device. 90 91 Example use: 92 93 ``docker -d --storage-opt "dm.mkfsarg=-O ^has_journal"`` 94 95 * `dm.mountopt` 96 97 Specifies extra mount options used when mounting the thin devices. 98 99 Example use: 100 101 ``docker -d --storage-opt dm.mountopt=nodiscard`` 102 103 * `dm.thinpooldev` 104 105 Specifies a custom blockdevice to use for the thin pool. 106 107 If using a block device for device mapper storage, ideally lvm2 108 would be used to create/manage the thin-pool volume that is then 109 handed to docker to exclusively create/manage the thin and thin 110 snapshot volumes needed for it's containers. Managing the thin-pool 111 outside of docker makes for the most feature-rich method of having 112 docker utilize device mapper thin provisioning as the backing 113 storage for docker's containers. lvm2-based thin-pool management 114 feature highlights include: automatic or interactive thin-pool 115 resize support, dynamically change thin-pool features, automatic 116 thinp metadata checking when lvm2 activates the thin-pool, etc. 117 118 Example use: 119 120 ``docker -d --storage-opt dm.thinpooldev=/dev/mapper/thin-pool`` 121 122 * `dm.datadev` 123 124 Specifies a custom blockdevice to use for data for the thin pool. 125 126 If using a block device for device mapper storage, ideally both 127 datadev and metadatadev should be specified to completely avoid 128 using the loopback device. 129 130 Example use: 131 132 ``docker -d --storage-opt dm.datadev=/dev/sdb1 --storage-opt dm.metadatadev=/dev/sdc1`` 133 134 * `dm.metadatadev` 135 136 Specifies a custom blockdevice to use for metadata for the thin 137 pool. 138 139 For best performance the metadata should be on a different spindle 140 than the data, or even better on an SSD. 141 142 If setting up a new metadata pool it is required to be valid. This 143 can be achieved by zeroing the first 4k to indicate empty 144 metadata, like this: 145 146 ``dd if=/dev/zero of=$metadata_dev bs=4096 count=1``` 147 148 Example use: 149 150 ``docker -d --storage-opt dm.datadev=/dev/sdb1 --storage-opt dm.metadatadev=/dev/sdc1`` 151 152 * `dm.blocksize` 153 154 Specifies a custom blocksize to use for the thin pool. The default 155 blocksize is 64K. 156 157 Example use: 158 159 ``docker -d --storage-opt dm.blocksize=512K`` 160 161 * `dm.blkdiscard` 162 163 Enables or disables the use of blkdiscard when removing 164 devicemapper devices. This is enabled by default (only) if using 165 loopback devices and is required to res-parsify the loopback file 166 on image/container removal. 167 168 Disabling this on loopback can lead to *much* faster container 169 removal times, but will make the space used in /var/lib/docker 170 directory not be returned to the system for other use when 171 containers are removed. 172 173 Example use: 174 175 ``docker -d --storage-opt dm.blkdiscard=false``