Hetzner Cloud Volume for Docker Volume Storage#
At the time of this writing, Hetzner volumes cost 0,052€ per GB per month.
Here we will show how to move /var/lib/docker
from instance storage to a
cloud volume.
Checklist#
create volume (this creates a temporary mount)
get disk UUID and update
/etc/fstab
stop services
move data
umount temporary volume
mount volume to
/var/lib/docker/
verify
start services
Commands#
du -sch /var/lib/docker/
docker ps # nothing running
df -T
# new disk is /dev/sdb mounted on /mnt/HC_Volume_123456789
dev=/dev/sdb
uuid=$(blkid -s UUID -o value $dev)
cat <<EOF >> /etc/fstab
/dev/disk/by-uuid/$uuid /var/lib/docker ext4 discard,nofail,defaults 0 0
EOF
systemctl stop docker.service
mv /var/lib/docker/* /mnt/HC_Volume_123456789/
ls -la /var/lib/docker # empty
ls -l /mnt/HC_Volume_123456789/
du -sch /var/lib/docker/
systemctl start docker.service
Resizing a Volume’s Filesystem#
You can resize a volume on the fly, but must increase the filesystem’s size afterwards. For ext4:
resize2fs /dev/sdb
Graph Odoo Request Duration with Loki
How to Upgrade Ubuntu from 20.04 to 22.04