Cloud config for docker & devicemapper with LVM

257 views
Skip to first unread message

Arthur Clément

unread,
Nov 15, 2016, 5:33:22 AM11/15/16
to coreos-user
Hi,

I didn't find any example on the web, so I put here my cloud config file to enable devicemapper with LVM for Docker, following Docker documentation: https://docs.docker.com/engine/userguide/storagedriver/device-mapper-driver/
It might help someone.

/var/lib/docker is wiped at each reboot (That's a wanted behaviour). I switched to devicemapper because I add so much trouble with overlayfs, it is not stable at all. With devicemapper I am not crossing my fingers anymore when I deploy big images.





    - name: fleet.service
      command: start
      drop-ins:
        - name: 10-wait-docker.conf
          content: |
            [Unit]
            After=docker.service
            Requires=docker.service

    - name: devicemapper-lvm-creation.service
      command: start
      content: |
        [Unit]
        Description=Create lvm volume
        After=dev-xvdb.device
        Requires=dev-xvdb.device
        [Service]
        Type=oneshot
        RemainAfterExit=yes
        ExecStart=-/usr/sbin/lvremove docker -y
        ExecStart=-/usr/sbin/vgremove docker -y
        ExecStart=-/usr/sbin/pvremove /dev/xvdb -y
        ExecStart=-/bin/rm -rf /var/lib/docker/
        ExecStart=/usr/sbin/pvcreate /dev/xvdb
        ExecStart=/usr/sbin/vgcreate docker /dev/xvdb
        ExecStart=/usr/sbin/lvcreate --wipesignatures y -n thinpool docker -l 95%VG -y
        ExecStart=/usr/sbin/lvcreate --wipesignatures y -n thinpoolmeta docker -l 1%VG
        ExecStart=/usr/sbin/lvconvert -y --zero n -c 512K --thinpool docker/thinpool --poolmetadata docker/thinpoolmeta

    - name: docker.service
      command: start
      drop-ins:
        - name: 50-devicemapper-storage-driver.conf
          content: |
            [Unit]
            After=devicemapper-lvm-creation.service
            Requires=devicemapper-lvm-creation.service
            [Service]
            Environment="DOCKER_OPTS=--storage-driver=devicemapper --storage-opt=dm.thinpooldev=/dev/mapper/docker-thinpool --storage-opt=dm.use_deferred_removal=true --storage-opt=dm.use_deferred_deletion=true"

write_files:
  - path: /etc/lvm/profile/docker-thinpool.profile
    permissions: 0644
    owner: root
    content: |
      activation
      {
        thin_pool_autoextend_threshold=80
        thin_pool_autoextend_percent=20
      }

Regards


Arthur Clément
DevOps


Brandon Philips

unread,
Nov 15, 2016, 5:01:21 PM11/15/16
to Arthur Clément, coreos-user
Thanks for sharing. What issues were you having with overlayfs and what workloads were you running?
--
You received this message because you are subscribed to the Google Groups "CoreOS User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coreos-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages