Random Notes‎ > ‎

Docker on LVM Thin Pool

posted Jul 25, 2015, 12:23 AM by William Shallum   [ updated Jul 25, 2015, 12:24 AM ]
These are notes on how to run docker on top of an LVM thin pool, which is nice if your system already has LVM and you have some spare space in the VG.

Tested on Arch. Instruction removes all docker data so maybe don't do it if you have data you care about?
  1. Create the thin pool from two LVs: one (larger) for data, the other (smaller) for metadata. man 7 lvmthin has examples.
  2. Customize the docker.service systemd unit file to add storage driver args specifying that it should use the thin pool.
    1. systemctl stop docker
    2. rm -rf /var/lib/docker you don't have anything there you want to keep do you?
    3. systemctl edit --full docker.service (much better than the copy / daemon-reload dance).
    4. Add to the ExecStart line: -s devicemapper --storage-opt dm.thinpooldev=name-under-dev-mapper and by name-under-dev-mapper I mean look under your /dev/mapper directory and use the name corresponding to your thin LV (will look like vgname-lvname). Using /dev/vgname/lvname leads to an interesting error.
    5. systemctl start docker
  3. journalctl -e any errors?
  4. docker info

Enjoy:

Storage Driver: devicemapper
 Pool Name: vg_laptop-docker--thinpool
 Pool Blocksize: 65.54 kB
 Backing Filesystem: xfs
 Data file:
 Metadata file:
 Data Space Used: 21.76 MB
 Data Space Total: 21.47 GB
 Data Space Available: 21.45 GB
 Metadata Space Used: 266.2 kB
 Metadata Space Total: 2.147 GB
 Metadata Space Available: 2.147 GB
 Udev Sync Supported: true
 Deferred Removal Enabled: false
 Library Version: 1.02.100 (2015-06-30)

References

  1. https://docs.docker.com/reference/commandline/daemon/#storage-driver-options
  2. lvmthin manpage
  3. http://jpetazzo.github.io/2014/01/29/docker-device-mapper-resize/
Comments