2014-03-27 16:48:32 +00:00
## devicemapper - a storage backend based on Device Mapper
### Theory of operation
The device mapper graphdriver uses the device mapper thin provisioning
2015-08-04 18:33:00 +00:00
module (dm-thinp) to implement CoW snapshots. The preferred model is
to have a thin pool reserved outside of Docker and passed to the
daemon via the `--storage-opt dm.thinpooldev` option.
As a fallback if no thin pool is provided, loopback files will be
created. Loopback is very slow, but can be used without any
pre-configuration of storage. It is strongly recommended that you do
not use loopback in production. Ensure your Docker daemon has a
`--storage-opt dm.thinpooldev` argument provided.
In loopback, a thin pool is created at `/var/lib/docker/devicemapper`
(devicemapper graph location) based on two block devices, one for
data and one for metadata. By default these block devices are created
automatically by using loopback mounts of automatically created sparse
2014-03-27 16:48:32 +00:00
files.
2015-08-04 18:33:00 +00:00
The default loopback files used are
`/var/lib/docker/devicemapper/devicemapper/data` and
`/var/lib/docker/devicemapper/devicemapper/metadata` . Additional metadata
required to map from docker entities to the corresponding devicemapper
volumes is stored in the `/var/lib/docker/devicemapper/devicemapper/json`
file (encoded as Json).
2014-03-27 16:48:32 +00:00
2014-08-06 01:11:32 +00:00
In order to support multiple devicemapper graphs on a system, the thin
2014-03-27 16:48:32 +00:00
pool will be named something like: `docker-0:33-19478248-pool` , where
2014-06-24 06:27:24 +00:00
the `0:33` part is the minor/major device nr and `19478248` is the
2015-08-04 18:33:00 +00:00
inode number of the `/var/lib/docker/devicemapper` directory.
2014-03-27 16:48:32 +00:00
2014-08-06 01:11:32 +00:00
On the thin pool, docker automatically creates a base thin device,
2014-03-27 16:48:32 +00:00
called something like `docker-0:33-19478248-base` of a fixed
2014-08-06 01:11:32 +00:00
size. This is automatically formatted with an empty filesystem on
creation. This device is the base of all docker images and
2014-03-27 16:48:32 +00:00
containers. All base images are snapshots of this device and those
images are then in turn used as snapshots for other images and
eventually containers.
2015-01-19 22:37:08 +00:00
### Information on `docker info`
As of docker-1.4.1, `docker info` when using the `devicemapper` storage driver
will display something like:
$ sudo docker info
[...]
Storage Driver: devicemapper
Pool Name: docker-253:1-17538953-pool
Pool Blocksize: 65.54 kB
2015-10-10 14:52:05 +00:00
Base Device Size: 107.4 GB
2015-01-19 22:37:08 +00:00
Data file: /dev/loop4
Metadata file: /dev/loop4
Data Space Used: 2.536 GB
Data Space Total: 107.4 GB
2015-01-31 06:21:34 +00:00
Data Space Available: 104.8 GB
2015-01-19 22:37:08 +00:00
Metadata Space Used: 7.93 MB
Metadata Space Total: 2.147 GB
2015-01-31 06:21:34 +00:00
Metadata Space Available: 2.14 GB
2015-01-19 22:37:08 +00:00
Udev Sync Supported: true
Data loop file: /home/docker/devicemapper/devicemapper/data
Metadata loop file: /home/docker/devicemapper/devicemapper/metadata
Library Version: 1.02.82-git (2013-10-04)
[...]
#### status items
Each item in the indented section under `Storage Driver: devicemapper` are
status information about the driver.
* `Pool Name` name of the devicemapper pool for this driver.
* `Pool Blocksize` tells the blocksize the thin pool was initialized with. This only changes on creation.
2015-10-10 14:52:05 +00:00
* `Base Device Size` tells the maximum size of a container and image
2015-01-19 22:37:08 +00:00
* `Data file` blockdevice file used for the devicemapper data
* `Metadata file` blockdevice file used for the devicemapper metadata
* `Data Space Used` tells how much of `Data file` is currently used
* `Data Space Total` tells max size the `Data file`
2015-02-09 22:51:48 +00:00
* `Data Space Available` tells how much free space there is in the `Data file` . If you are using a loop device this will report the actual space available to the loop device on the underlying filesystem.
2015-01-19 22:37:08 +00:00
* `Metadata Space Used` tells how much of `Metadata file` is currently used
* `Metadata Space Total` tells max size the `Metadata file`
2015-02-09 22:51:48 +00:00
* `Metadata Space Available` tells how much free space there is in the `Metadata file` . If you are using a loop device this will report the actual space available to the loop device on the underlying filesystem.
2015-01-19 22:37:08 +00:00
* `Udev Sync Supported` tells whether devicemapper is able to sync with Udev. Should be `true` .
* `Data loop file` file attached to `Data file` , if loopback device is used
* `Metadata loop file` file attached to `Metadata file` , if loopback device is used
* `Library Version` from the libdevmapper used
2015-06-29 03:04:24 +00:00
### About the devicemapper options
2014-03-27 16:48:32 +00:00
The devicemapper backend supports some options that you can specify
2014-08-06 01:11:32 +00:00
when starting the docker daemon using the `--storage-opt` flags.
2015-08-10 12:48:08 +00:00
This uses the `dm` prefix and would be used something like `docker daemon --storage-opt dm.foo=bar` .
2014-03-27 16:48:32 +00:00
2015-06-29 03:04:24 +00:00
These options are currently documented both in [the man
page](../../../man/docker.1.md) and in [the online
documentation](https://docs.docker.com/reference/commandline/daemon/#docker-
execdriver-option). If you add an options, update both the `man` page and the
documentation.