Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

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!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
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 /