Signed-off-by: Shishir Mahajan <shishir.mahajan@redhat.com>
| ... | ... |
@@ -3,22 +3,33 @@ |
| 3 | 3 |
### Theory of operation |
| 4 | 4 |
|
| 5 | 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 |
|
| 6 |
+module (dm-thinp) to implement CoW snapshots. The preferred model is |
|
| 7 |
+to have a thin pool reserved outside of Docker and passed to the |
|
| 8 |
+daemon via the `--storage-opt dm.thinpooldev` option. |
|
| 9 |
+ |
|
| 10 |
+As a fallback if no thin pool is provided, loopback files will be |
|
| 11 |
+created. Loopback is very slow, but can be used without any |
|
| 12 |
+pre-configuration of storage. It is strongly recommended that you do |
|
| 13 |
+not use loopback in production. Ensure your Docker daemon has a |
|
| 14 |
+`--storage-opt dm.thinpooldev` argument provided. |
|
| 15 |
+ |
|
| 16 |
+In loopback, a thin pool is created at `/var/lib/docker/devicemapper` |
|
| 17 |
+(devicemapper graph location) based on two block devices, one for |
|
| 18 |
+data and one for metadata. By default these block devices are created |
|
| 19 |
+automatically by using loopback mounts of automatically created sparse |
|
| 11 | 20 |
files. |
| 12 | 21 |
|
| 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). |
|
| 22 |
+The default loopback files used are |
|
| 23 |
+`/var/lib/docker/devicemapper/devicemapper/data` and |
|
| 24 |
+`/var/lib/docker/devicemapper/devicemapper/metadata`. Additional metadata |
|
| 25 |
+required to map from docker entities to the corresponding devicemapper |
|
| 26 |
+volumes is stored in the `/var/lib/docker/devicemapper/devicemapper/json` |
|
| 27 |
+file (encoded as Json). |
|
| 17 | 28 |
|
| 18 | 29 |
In order to support multiple devicemapper graphs on a system, the thin |
| 19 | 30 |
pool will be named something like: `docker-0:33-19478248-pool`, where |
| 20 | 31 |
the `0:33` part is the minor/major device nr and `19478248` is the |
| 21 |
-inode number of the $graph directory. |
|
| 32 |
+inode number of the `/var/lib/docker/devicemapper` directory. |
|
| 22 | 33 |
|
| 23 | 34 |
On the thin pool, docker automatically creates a base thin device, |
| 24 | 35 |
called something like `docker-0:33-19478248-base` of a fixed |
| ... | ... |
@@ -1397,6 +1397,12 @@ func (devices *DeviceSet) initDevmapper(doInit bool) error {
|
| 1397 | 1397 |
} |
| 1398 | 1398 |
} |
| 1399 | 1399 |
|
| 1400 |
+ if devices.thinPoolDevice == "" {
|
|
| 1401 |
+ if devices.metadataLoopFile != "" || devices.dataLoopFile != "" {
|
|
| 1402 |
+ logrus.Warnf("Usage of loopback devices is strongly discouraged for production use. Please use `--storage-opt dm.thinpooldev` or use `man docker` to refer to dm.thinpooldev section.")
|
|
| 1403 |
+ } |
|
| 1404 |
+ } |
|
| 1405 |
+ |
|
| 1400 | 1406 |
// Right now this loads only NextDeviceID. If there is more metadata |
| 1401 | 1407 |
// down the line, we might have to move it earlier. |
| 1402 | 1408 |
if err := devices.loadDeviceSetMetaData(); err != nil {
|
| ... | ... |
@@ -192,6 +192,12 @@ options for `zfs` start with `zfs`. |
| 192 | 192 |
resize support, dynamically changing thin-pool features, automatic thinp |
| 193 | 193 |
metadata checking when lvm activates the thin-pool, etc. |
| 194 | 194 |
|
| 195 |
+ As a fallback if no thin pool is provided, loopback files will be |
|
| 196 |
+ created. Loopback is very slow, but can be used without any |
|
| 197 |
+ pre-configuration of storage. It is strongly recommended that you do |
|
| 198 |
+ not use loopback in production. Ensure your Docker daemon has a |
|
| 199 |
+ `--storage-opt dm.thinpooldev` argument provided. |
|
| 200 |
+ |
|
| 195 | 201 |
Example use: |
| 196 | 202 |
|
| 197 | 203 |
docker daemon --storage-opt dm.thinpooldev=/dev/mapper/thin-pool |