hi, I’m looking to get started on Digitalocean with a docker vm. Now, the currently recommended way to run Docker is through direct-lvm. This pretty much means creating a volume and doing
lvcreate --wipesignatures y -n data direct-lvm -l 95%VG
lvcreate --wipesignatures y -n metadata direct-lvm -l 5%VG
is this viable on Digitalocean ?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Using direct-lvm requires a free block device. DigitalOcean Droplets are setup with a single partition by default which makes this slightly difficult. Though with the addition of block storage (currently in beta), it becomes much easier.
For example, booting up a new 16.04 Droplet with Docker installed and a block storage volume attached, we can see the free device at sda as well as the loopback device created by Docker’s defaults:
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
vda 253:0 0 30G 0 disk
└─vda1 253:1 0 30G 0 part /
loop0 7:0 0 100G 0 loop
└─docker-253:1-784525-pool 252:0 0 100G 0 dm
loop1 7:1 0 2G 0 loop
└─docker-253:1-784525-pool 252:0 0 100G 0 dm
For all the information setting up direct-lvm mode for production see the Docker documentation. Though, here’s a quick run through. First we will stop Docker and then create a new volume and thin pool.
- sudo systemctl stop docker
- rm -rf /var/lib/docker/*
- pvcreate /dev/sda
- vgcreate docker /dev/sda
- lvcreate --wipesignatures y -n thinpool docker -l 95%VG
- lvcreate --wipesignatures y -n thinpoolmeta docker -l 1%VG
- lvconvert -y --zero n -c 512K --thinpool docker/thinpool --poolmetadata docker/thinpoolmeta
Now edit the file /etc/lvm/profile/docker-thinpool.profile to configure auto-extending of the thin pool:
activation {
thin_pool_autoextend_threshold=80
thin_pool_autoextend_percent=20
}
Next, apply the change:
- lvchange --metadataprofile docker-thinpool docker/thinpool
Then, we will configure Docker itself to use the new device. This can be done with command line arguments when starting Docker, but with systemd it is simpler to edit /etc/docker/daemon.json to include:
{
"storage-driver": "devicemapper",
"storage-opts": [
"dm.thinpooldev=/dev/mapper/docker-thinpool",
"dm.use_deferred_removal=true"
]
}
Finally, let’s restart Docker:
- systemctl daemon-reload
- systemctl start docker
Now that we’re done, you can see that the loopback device is gone and sda has been configured for LVM:
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
├─docker-thinpool_tmeta 252:0 0 1020M 0 lvm
│ └─docker-thinpool 252:2 0 95G 0 lvm
└─docker-thinpool_tdata 252:1 0 95G 0 lvm
└─docker-thinpool 252:2 0 95G 0 lvm
vda 253:0 0 30G 0 disk
└─vda1 253:1 0 30G 0 part /
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.