Featured image of post Docker Storage Driver - Devicemapper

Docker Storage Driver - Devicemapper

Docker relies on storage engines to layer images. The default storage driver depends on who packaged docker for your OS. Fortunately, it’s not too difficult to change; However you may lose your images and containers so it’s best to decide on a driver when you begin.

Storage Driver Options

Currently (docker 1.11) has the following engines available:

Technology Driver Name
OverlayFS overlay
AUFS aufs
Btrfs btrfs
Device Mapper devicemapper
VFS* vfs
ZFS zfs

To see your current storage driver try:

docker info | grep -i "storage driver"
Storage Driver: devicemapper

Setting up Device Mapper Driver

Choosing the right storage engine requires some reading. Personally, I went with devicemapper direct-lvm since I have experience working with lvm and it seems to be well supported by docker. Here is how I got it configured on a fresh docker host running centOS 7:

# stop docker
root@c7-1 ~ $ systemctl stop docker

# create your vg,lv
root@c7-1 ~ $ lvcreate --wipesignatures y -n thinpool vg-docker -l 95%VG
Logical volume "thinpool" created.

root@c7-1 ~ $ lvcreate --wipesignatures y -n thinpoolmeta vg-docker -l 1%VG
Logical volume "thinpoolmeta" created.

root@c7-1 ~ $ lvconvert -y --zero n -c 512K --thinpool vg-docker/thinpool --poolmetadata vg-docker/thinpoolmeta
WARNING: Converting logical volume vg-docker/thinpool and vg-docker/thinpoolmeta to pool's data and metadata volumes.
Converted vg-docker/thinpool to thin pool.

# create this lvm profile
root@c7-1 ~ $ cat /etc/lvm/profile/docker-thinpool.profile
activation {

# apply the above profile, and verify that your lv is being monitored
root@c7-1 ~ $ lvchange --metadataprofile docker-thinpool vg-docker/thinpool
Logical volume "thinpool" changed.

root@c7-1 ~ $ lvs -o+seg_monitor
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert Monitor
thinpool vg-docker twi-a-t--- 28.50g 0.00 0.02 monitored

# configure docker deamon
root@c7-1 ~ $ cat /etc/docker/daemon.json
         "storage-driver": "devicemapper",
         "storage-opts": [

# This will delete all your images and containers!
root@c7-1 ~ $ rm -rf /var/lib/docker/*

# start docker
root@c7-1 ~ $ systemctl start docker

# verify
Server Version: 1.11.0
Storage Driver: devicemapper
Pool Name: vg--docker-thinpool
Pool Blocksize: 524.3 kB
Base Device Size: 10.74 GB
Backing Filesystem: xfs
Data file:
Metadata file:
Data Space Used: 320.3 MB
Data Space Total: 30.6 GB
Data Space Available: 30.28 GB
Metadata Space Used: 180.2 kB
Metadata Space Total: 318.8 MB
Metadata Space Available: 318.6 MB
Udev Sync Supported: true
Deferred Removal Enabled: true
Deferred Deletion Enabled: false
Deferred Deleted Device Count: 0
Library Version: 1.02.107-RHEL7 (2015-12-01)
comments powered by Disqus
Built with Hugo, using a modified version of the Stack theme.