Back to articles
AI & Cloud

Optimizing Docker Storage Driver with Btrfs or ZFS on VPS: Solutions for Faster Read/Write and Storage Savings

A detailed guide on optimizing Docker storage drivers with Btrfs or ZFS on VPS to improve read/write speeds and save disk space, ideal for AI workloads, self-hosted LLMs, and API...

DPTCloud Engineering4 min read
Optimizing Docker Storage Driver with Btrfs or ZFS on VPS: Solutions for Faster Read/Write and Storage Savings

Optimizing Docker with Btrfs or ZFS on VPS

Using Docker on VPS is increasingly common, especially for AI applications, self-hosted LLMs, and API gateways. However, Docker's default storage driver, overlay2, may not be optimal in terms of performance and storage efficiency. Btrfs and ZFS are modern filesystems that support snapshotting, compression, and deduplication, enabling faster read/write operations and better disk space utilization. This guide walks you through optimizing Docker with Btrfs or ZFS on a VPS.

Prerequisites

  • VPS running Linux (Ubuntu 22.04 or Debian 11+)
  • An unused hard drive (e.g., /dev/sdb)
  • Docker Engine installed
  • Btrfs or ZFS utilities installed

Install and Configure Btrfs or ZFS

First, format the unused drive with Btrfs or ZFS. Here’s an example using Btrfs:

sudo mkfs.btrfs /dev/sdb
sudo mkdir /mnt/btrfs
sudo mount /dev/sdb /mnt/btrfs

For ZFS:

sudo zpool create data /dev/sdb
sudo zfs create data/docker
sudo zfs set mountpoint=/mnt/zfs data/docker

Change Docker Storage Driver

To make Docker use Btrfs or ZFS, edit the Docker daemon configuration file /etc/docker/daemon.json:

{
  "storage-driver": "btrfs",
  "data-root": "/mnt/btrfs/docker"
}

Or for ZFS:

{
  "storage-driver": "zfs",
  "data-root": "/mnt/zfs/docker"
}

After saving, restart Docker:

sudo systemctl restart docker

Verify Configuration

Check that Docker is using the correct storage driver:

docker info | grep "Storage Driver"

The output should show:

Storage Driver: btrfs

Or:

Storage Driver: zfs

Performance and Storage Savings

Btrfs and ZFS support automatic compression. Check space savings:

sudo btrfs filesystem usage /mnt/btrfs
sudo zfs get used,compressratio data/docker

Compression reduces storage usage, especially effective for large AI models and logs.

Troubleshooting

  • Docker fails to start: Check /var/log/docker.log for storage driver errors.
  • Storage driver not shown in docker info: Ensure Docker restarted and daemon.json is correctly formatted.
  • Insufficient disk space: Verify available space on the drive.

References

DPTCloud Tier III Infrastructure

High-RAM Cloud VPS Plans Optimized for AI, Databases & Cache

Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.

View 22 VPS Plans
ECO · vn-02Recommended

VPS-4E

297.000 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe
ECO · vn-02

VPS-5E

614.900 ₫ / mo

10% VAT included

  • CPU: 8 vCPU
  • RAM: 16 GB
  • SSD: 100 GB NVMe
ADVANCED · vn-03Recommended

VPS-4T

548.900 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe

Related Articles

View all
ZaloZalo SupportDiscord0384 753 478