Browse code

Fixes #21701 devicemapper docs Copy edit the content Updates to existing material Adding mbentley's comments Updating with last minute comments Update with Seb's comments

Signed-off-by: Mary Anthony <mary@docker.com>

Mary Anthony authored on 2016/04/13 04:20:03
Showing 3 changed files
... ...
@@ -195,17 +195,17 @@ options for `zfs` start with `zfs`.
195 195
      to create and manage the thin-pool volume. This volume is then handed to Docker
196 196
      to exclusively create snapshot volumes needed for images and containers.
197 197
 
198
-     Managing the thin-pool outside of Docker makes for the most feature-rich
198
+     Managing the thin-pool outside of Engine makes for the most feature-rich
199 199
      method of having Docker utilize device mapper thin provisioning as the
200
-     backing storage for Docker's containers. The highlights of the lvm-based
200
+     backing storage for Docker containers. The highlights of the lvm-based
201 201
      thin-pool management feature include: automatic or interactive thin-pool
202 202
      resize support, dynamically changing thin-pool features, automatic thinp
203 203
      metadata checking when lvm activates the thin-pool, etc.
204 204
 
205
-     As a fallback if no thin pool is provided, loopback files will be
205
+     As a fallback if no thin pool is provided, loopback files are
206 206
      created. Loopback is very slow, but can be used without any
207 207
      pre-configuration of storage. It is strongly recommended that you do
208
-     not use loopback in production. Ensure your Docker daemon has a
208
+     not use loopback in production. Ensure your Engine daemon has a
209 209
      `--storage-opt dm.thinpooldev` argument provided.
210 210
 
211 211
      Example use:
... ...
@@ -441,29 +441,33 @@ options for `zfs` start with `zfs`.
441 441
 
442 442
 *  `dm.min_free_space`
443 443
 
444
-    Specifies the min free space percent in thin pool require for new device
444
+    Specifies the min free space percent in a thin pool require for new device
445 445
     creation to succeed. This check applies to both free data space as well
446 446
     as free metadata space. Valid values are from 0% - 99%. Value 0% disables
447
-    free space checking logic. If user does not specify a value for this optoin,
448
-    then default value for this option is 10%.
447
+    free space checking logic. If user does not specify a value for this option,
448
+    the Engine uses a default value of 10%.
449 449
 
450
-    Whenever a new thin pool device is created (during docker pull or
451
-    during container creation), docker will check minimum free space is
452
-    available as specified by this parameter. If that is not the case, then
453
-    device creation will fail and docker operation will fail.
450
+    Whenever a new a thin pool device is created (during `docker pull` or during
451
+    container creation), the Engine checks if the minimum free space is
452
+    available. If sufficient space is unavailable, then device creation fails
453
+    and any relevant `docker` operation fails.
454 454
 
455
-    One will have to create more free space in thin pool to recover from the
456
-    error. Either delete some of the images and containers from thin pool and
457
-    create free space or add more storage to thin pool.
455
+    To recover from this error, you must create more free space in the thin pool
456
+    to recover from the error. You can create free space by deleting some images
457
+    and containers from the thin pool. You can also add more storage to the thin
458
+    pool.
458 459
 
459
-    For lvm thin pool, one can add more storage to volume group container thin
460
-    pool and that should automatically resolve it. If loop devices are being
461
-    used, then stop docker, grow the size of loop files and restart docker and
462
-    that should resolve the issue.
460
+    To add more space to a LVM (logical volume management) thin pool, just add
461
+    more storage to the volume group container thin pool; this should automatically
462
+    resolve any errors. If your configuration uses loop devices, then stop the
463
+    Engine daemon, grow the size of loop files and restart the daemon to resolve
464
+    the issue.
463 465
 
464 466
     Example use:
465 467
 
466
-        $ docker daemon --storage-opt dm.min_free_space=10%
468
+    ```bash
469
+    $ docker daemon --storage-opt dm.min_free_space=10%
470
+    ```
467 471
 
468 472
 Currently supported options of `zfs`:
469 473
 
... ...
@@ -17,7 +17,9 @@ for image and container management. This article refers to the Device Mapper
17 17
 storage driver as `devicemapper`, and the kernel framework as `Device Mapper`.
18 18
 
19 19
 
20
->**Note**: The [Commercially Supported Docker Engine (CS-Engine) running on RHEL and CentOS Linux](https://www.docker.com/compatibility-maintenance) requires that you use the `devicemapper` storage driver.
20
+>**Note**: The [Commercially Supported Docker Engine (CS-Engine) running on RHEL
21
+and CentOS Linux](https://www.docker.com/compatibility-maintenance) requires
22
+that you use the `devicemapper` storage driver.
21 23
 
22 24
 
23 25
 ## An alternative to AUFS
... ...
@@ -206,103 +208,155 @@ mode uses block devices to create the thin pool. The following procedure shows
206 206
 you how to configure a Docker host to use the `devicemapper` storage driver in
207 207
 a `direct-lvm` configuration.
208 208
 
209
-> **Caution:** If you have already run the Docker daemon on your Docker host
209
+> **Caution:** If you have already run the Engine daemon on your Docker host
210 210
 > and have images you want to keep, `push` them Docker Hub or your private
211 211
 > Docker Trusted Registry before attempting this procedure.
212 212
 
213 213
 The procedure below will create a 90GB data volume and 4GB metadata volume to
214 214
 use as backing for the storage pool. It assumes that you have a spare block
215
-device at `/dev/xvdf` with enough free space to complete the task. The device
215
+device at `/dev/sdd` with enough free space to complete the task. The device
216 216
 identifier and volume sizes may be be different in your environment and you
217
-should substitute your own values throughout the procedure. The procedure also
218
-assumes that the Docker daemon is in the `stopped` state.
217
+should substitute your own values throughout the procedure.
219 218
 
220
-1. Log in to the Docker host you want to configure and stop the Docker daemon.
219
+The procedure also assumes that the Engine daemon is in the `stopped` state.
220
+Any existing images or data are lost by this process.
221 221
 
222
-2. If it exists, delete your existing image store by removing the
223
-`/var/lib/docker` directory.
222
+1. Log in to the Docker host you want to configure.
223
+2. If it is running, stop the Engine daemon.
224
+3. Install the logical volume management version 2.
224 225
 
225
-        $ sudo rm -rf /var/lib/docker
226
+    ```bash
227
+    $ yum install lvm2
228
+    ```
229
+4. Create a physical volume replacing `/dev/sdd` with your block device.
226 230
 
227
-3. Create an LVM physical volume (PV) on your spare block device using the
228
-`pvcreate` command.
231
+    ```bash
232
+    $ pvcreate /dev/sdd
233
+  ```
229 234
 
230
-        $ sudo pvcreate /dev/xvdf
231
-        Physical volume `/dev/xvdf` successfully created
235
+5. Create a 'docker' volume group.
232 236
 
233
-    The device identifier may be different on your system. Remember to
234
-substitute your value in the command above.
237
+    ```bash
238
+    $ vgcreate docker /dev/sdd
239
+    ```
235 240
 
236
-4. Create a new volume group (VG) called `vg-docker` using the PV created in
237
-the previous step.
241
+6. Create a thin pool named `thinpool`.
238 242
 
239
-        $ sudo vgcreate vg-docker /dev/xvdf
240
-        Volume group `vg-docker` successfully created
243
+    In this example, the data logical is 95% of the 'docker' volume group size.
244
+    Leaving this free space allows for auto expanding of either the data or
245
+    metadata if space runs low as a temporary stopgap.
241 246
 
242
-5. Create a new 90GB logical volume (LV) called `data` from space in the
243
-`vg-docker` volume group.
247
+    ```bash
248
+   $ lvcreate --wipesignatures y -n thinpool docker -l 95%VG
249
+   $ lvcreate --wipesignatures y -n thinpoolmeta docker -l 1%VG
250
+   ```
244 251
 
245
-        $ sudo lvcreate -L 90G -n data vg-docker
246
-        Logical volume `data` created.
252
+7. Convert the pool to a thin pool.
247 253
 
248
-    The command creates an LVM logical volume called `data` and an associated
249
-block device file at `/dev/vg-docker/data`. In a later step, you instruct the
250
-`devicemapper` storage driver to use this block device to store image and
251
-container data.
254
+    ```bash
255
+    $ lvconvert -y --zero n -c 512K --thinpool docker/thinpool --poolmetadata docker/thinpoolmeta
256
+    ```
252 257
 
253
-    If you receive a signature detection warning, make sure you are working on
254
-the correct devices before continuing. Signature warnings indicate that the
255
-device you're working on is currently in use by LVM or has been used by LVM in
256
-the past.
258
+8. Configure autoextension of thin pools via an `lvm` profile.
257 259
 
258
-6. Create a new logical volume (LV) called `metadata` from space in the
259
-`vg-docker` volume group.
260
+    ```bash
261
+    $ vi /etc/lvm/profile/docker-thinpool.profile
262
+    ```
260 263
 
261
-        $ sudo lvcreate -L 4G -n metadata vg-docker
262
-        Logical volume `metadata` created.
264
+9. Specify 'thin_pool_autoextend_threshold' value.
263 265
 
264
-    This creates an LVM logical volume called `metadata` and an associated
265
-block device file at `/dev/vg-docker/metadata`. In the next step you instruct
266
-the `devicemapper` storage driver to use this block device to store image and
267
-container metadata.
266
+    The value should be the percentage of space used before `lvm` attempts
267
+    to autoextend the available space (100 = disabled).
268 268
 
269
-7. Start the Docker daemon with the `devicemapper` storage driver and the
270
-`--storage-opt` flags.
269
+    ```
270
+    thin_pool_autoextend_threshold = 80
271
+    ```
271 272
 
272
-    The `data` and `metadata` devices that you pass to the `--storage-opt`
273
-options were created in the previous steps.
273
+10. Modify the `thin_pool_autoextend_percent` for when thin pool autoextension occurs.
274 274
 
275
-          $ sudo docker daemon --storage-driver=devicemapper --storage-opt dm.datadev=/dev/vg-docker/data --storage-opt dm.metadatadev=/dev/vg-docker/metadata &
276
-          [1] 2163
277
-          [root@ip-10-0-0-75 centos]# INFO[0000] Listening for HTTP on unix (/var/run/docker.sock)
278
-          INFO[0027] Option DefaultDriver: bridge
279
-          INFO[0027] Option DefaultNetwork: bridge
280
-          <output truncated>
281
-          INFO[0027] Daemon has completed initialization
282
-          INFO[0027] Docker daemon commit=1b09a95-unsupported graphdriver=aufs version=1.11.0-dev
275
+    The value's setting is the perentage of space to increase the thin pool (100 =
276
+    disabled)
283 277
 
284
-    It is also possible to set the `--storage-driver` and `--storage-opt` flags
285
- in the Docker config file and start the daemon normally using the `service` or
286
- `systemd` commands.
278
+    ```
279
+    thin_pool_autoextend_percent = 20
280
+    ```
287 281
 
288
-8. Use the `docker info` command to verify that the daemon is using `data` and
289
-`metadata` devices you created.
282
+11. Check your work, your `docker-thinpool.profile` file should appear similar to the following:
290 283
 
291
-        $ sudo docker info
292
-        INFO[0180] GET /v1.20/info
293
-        Containers: 0
294
-        Images: 0
295
-        Storage Driver: devicemapper
296
-         Pool Name: docker-202:1-1032-pool
297
-         Pool Blocksize: 65.54 kB
298
-         Backing Filesystem: xfs
299
-         Data file: /dev/vg-docker/data
300
-         Metadata file: /dev/vg-docker/metadata
301
-        [...]
284
+    An example `/etc/lvm/profile/docker-thinpool.profile` file:
285
+
286
+    ```
287
+     activation {
288
+         thin_pool_autoextend_threshold=80
289
+         thin_pool_autoextend_percent=20
290
+     }
291
+     ```
292
+
293
+12. Apply your new lvm profile
294
+
295
+    ```bash
296
+    $ lvchange --metadataprofile docker-thinpool docker/thinpool
297
+  ```
298
+
299
+13. Verify the `lv` is monitored.
300
+
301
+    ```bash
302
+    $ lvs -o+seg_monitor
303
+    ```
304
+
305
+14. If Engine was previously started, clear your graph driver directory.
306
+
307
+    Clearing your graph driver removes any images and containers in your Docker
308
+    installation.
309
+
310
+    ```bash
311
+    $ rm -rf /var/lib/docker/*
312
+    ```
313
+
314
+14. Configure the Engine daemon with specific devicemapper options.
315
+
316
+    There are two ways to do this. You can set options on the commmand line if you start the daemon there:
317
+
318
+    ```bash
319
+    --storage-driver=devicemapper --storage-opt=dm.thinpooldev=/dev/mapper/docker-thinpool --storage-opt dm.use_deferred_removal=true
320
+    ```
321
+
322
+    You can also set them for startup in the `daemon.json` configuration, for example:
323
+
324
+    ```json
325
+     {
326
+             "storage-driver": "devicemapper",
327
+             "storage-opts": [
328
+                     "dm.thinpooldev=/dev/mapper/docker-thinpool",
329
+                     "dm.use_deferred_removal=true"
330
+             ]
331
+     }
332
+    ```
333
+15. Start the Engine daemon.
334
+
335
+    ```bash
336
+    $ systemctl start docker
337
+    ```
338
+
339
+After you start the Engine daemon, ensure you monitor your thin pool and volume
340
+group free space. While the volume group will auto-extend, it can still fill
341
+up. To monitor logical volumes, use `lvs` without options or `lvs -a` to see tha
342
+data and metadata sizes. To monitor volume group free space, use the `vgs` command.
343
+
344
+Logs can show the auto-extension of the thin pool when it hits the threshold, to
345
+view the logs use:
346
+
347
+```bash
348
+journalctl -fu dm-event.service
349
+```
350
+
351
+If you run into repeated problems with thin pool, you can use the
352
+`dm.min_free_space` option to tune the Engine behavior. This value ensures that
353
+operations fail with a warning when the free space is at or near the minimum.
354
+For information, see <a
355
+href="https://docs.docker.com/engine/reference/commandline/daemon/#storage-driver-options"
356
+target="_blank">the storage driver options in the Engine daemon reference</a>.
302 357
 
303
-    The output of the command above shows the storage driver as `devicemapper`.
304
- The last two lines also confirm that the correct devices are being used for
305
-the `Data file` and the `Metadata file`.
306 358
 
307 359
 ### Examine devicemapper structures on the host
308 360
 
... ...
@@ -336,7 +390,7 @@ Docker-MAJ:MIN-INO-pool
336 336
 
337 337
 Because Device Mapper operates at the block level it is more difficult to see
338 338
 diffs between image layers and containers. Docker 1.10 and later no longer
339
-matches image layer IDs with directory names in `/var/lib/docker`.  However,
339
+matches image layer IDs with directory names in `/var/lib/docker`. However,
340 340
 there are two key directories. The `/var/lib/docker/devicemapper/mnt` directory
341 341
  contains the mount points for image and container layers. The
342 342
 `/var/lib/docker/devicemapper/metadata`directory contains one file for every
... ...
@@ -410,3 +464,4 @@ data volumes.
410 410
 * [Select a storage driver](selectadriver.md)
411 411
 * [AUFS storage driver in practice](aufs-driver.md)
412 412
 * [Btrfs storage driver in practice](btrfs-driver.md)
413
+* [daemon reference](../../reference/commandline/daemon#storage-driver-options)
... ...
@@ -269,19 +269,27 @@ allocating images and container snapshots.
269 269
 
270 270
 Specifies a custom block storage device to use for the thin pool.
271 271
 
272
-If using a block device for device mapper storage, it is best to use
273
-`lvm` to create and manage the thin-pool volume. This volume is then
274
-handed to Docker to create snapshot volumes needed for images and
275
-containers.
272
+If using a block device for device mapper storage, it is best to use `lvm`
273
+to create and manage the thin-pool volume. This volume is then handed to Docker
274
+to exclusively create snapshot volumes needed for images and containers.
276 275
 
277
-Managing the thin-pool outside of Docker makes for the most feature-rich method
278
-of having Docker utilize device mapper thin provisioning as the backing storage
279
-for Docker's containers. The highlights of the LVM-based thin-pool management
280
-feature include: automatic or interactive thin-pool resize support, dynamically
281
-changing thin-pool features, automatic thinp metadata checking when lvm activates
282
-the thin-pool, etc.
276
+Managing the thin-pool outside of Engine makes for the most feature-rich
277
+method of having Docker utilize device mapper thin provisioning as the
278
+backing storage for Docker containers. The highlights of the lvm-based
279
+thin-pool management feature include: automatic or interactive thin-pool
280
+resize support, dynamically changing thin-pool features, automatic thinp
281
+metadata checking when lvm activates the thin-pool, etc.
283 282
 
284
-Example use: `docker daemon --storage-opt dm.thinpooldev=/dev/mapper/thin-pool`
283
+As a fallback if no thin pool is provided, loopback files are
284
+created. Loopback is very slow, but can be used without any
285
+pre-configuration of storage. It is strongly recommended that you do
286
+not use loopback in production. Ensure your Engine daemon has a
287
+`--storage-opt dm.thinpooldev` argument provided.
288
+
289
+Example use:
290
+
291
+   $ docker daemon \
292
+         --storage-opt dm.thinpooldev=/dev/mapper/thin-pool
285 293
 
286 294
 #### dm.basesize
287 295
 
... ...
@@ -471,27 +479,29 @@ daemon with a supported environment.
471 471
 
472 472
 #### dm.min_free_space
473 473
 
474
-Specifies the min free space percent in thin pool require for new device
474
+Specifies the min free space percent in a thin pool require for new device
475 475
 creation to succeed. This check applies to both free data space as well
476 476
 as free metadata space. Valid values are from 0% - 99%. Value 0% disables
477
-free space checking logic. If user does not specify a value for this optoin,
478
-then default value for this option is 10%.
479
-
480
-Whenever a new thin pool device is created (during docker pull or
481
-during container creation), docker will check minimum free space is
482
-available as specified by this parameter. If that is not the case, then
483
-device creation will fail and docker operation will fail.
484
-
485
-One will have to create more free space in thin pool to recover from the
486
-error. Either delete some of the images and containers from thin pool and
487
-create free space or add more storage to thin pool.
488
-
489
-For lvm thin pool, one can add more storage to volume group container thin
490
-pool and that should automatically resolve it. If loop devices are being
491
-used, then stop docker, grow the size of loop files and restart docker and
492
-that should resolve the issue.
493
-
494
-Example use: `docker daemon --storage-opt dm.min_free_space=10%`
477
+free space checking logic. If user does not specify a value for this option,
478
+the Engine uses a default value of 10%.
479
+
480
+Whenever a new a thin pool device is created (during `docker pull` or during
481
+container creation), the Engine checks if the minimum free space is
482
+available. If the space is unavailable, then device creation fails and any
483
+relevant `docker` operation fails.
484
+
485
+To recover from this error, you must create more free space in the thin pool to
486
+recover from the error. You can create free space by deleting some images
487
+and containers from tge thin pool. You can also add
488
+more storage to the thin pool.
489
+
490
+To add more space to an LVM (logical volume management) thin pool, just add
491
+more storage to the  group container thin pool; this should automatically
492
+resolve any errors. If your configuration uses loop devices, then stop the
493
+Engine daemon, grow the size of loop files and restart the daemon to resolve
494
+the issue.
495
+
496
+Example use:: `docker daemon --storage-opt dm.min_free_space=10%`
495 497
 
496 498
 ## ZFS options
497 499