User-defined Playground

Docker on Btrfs Playground

Hands-on Docker on Btrfs: experiment with native snapshots, compression, and checksums; inspect setup, grow the filesystem live, and back up/restore images and containers.

Startup configuration
docker-01
Docker on Btrfs playground: Hands-on Docker on Btrfs: experiment with native snapshots, compression, and checksums; inspect setup, grow the filesystem live, and back up/restore images and containers.

Motivation

This playground demonstrates Docker using the Btrfs storage driver. Use it to experiment with running Docker on Btrfs (instead of the default overlay2):

  • Inspect the setup (lsblk, docker info, btrfs filesystem show, etc.)
  • Practice online growth of the Btrfs filesystem (add a device, then rebalance)
  • Set up Btrfs usage monitoring (e.g., btrfs filesystem usage)
  • Back up and restore images/containers with snapshots and btrfs send/receive.
  • etc.

Under the hood

The playground's single VM is an Ubuntu Server with Docker Engine preinstalled. It has four drives:

  • The root filesystem (ext4) resides on /dev/vda.
  • /dev/vdb and /dev/vdc form a multi-device Btrfs filesystem.
  • That Btrfs filesystem is mounted at /var/lib/docker (Docker's data-root).
  • The fourth drive (/dev/vdd) is unused and available to grow the Btrfs filesystem.
lsblk
NAME
    MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
vda 254:0    0  10G  0 disk /
vdb 254:16   0  15G  0 disk /var/lib/docker/btrfs
                            /var/lib/docker
vdc 254:32   0  15G  0 disk 
vdd 254:48   0  10G  0 disk 

Initial Btrfs filesystem configuration:

sudo btrfs filesystem show
Label: none  uuid: 1739f1bd-af61-43a5-b9ad-65921c9a50a4
        Total devices 2 FS bytes used 144.00KiB
        devid    1 size 15.00GiB used 272.00MiB path /dev/vdb
        devid    2 size 15.00GiB used 264.00MiB path /dev/vdc

The Docker daemon is already configured to use Btrfs:

cat /etc/docker/daemon.json
{
    "storage-driver": "btrfs",
    ...other options
}

To grow the filesystem without restarting the Docker daemon (and any running containers):

sudo btrfs device add /dev/vdd /var/lib/docker
sudo btrfs filesystem balance start /var/lib/docker
sudo btrfs filesystem show
Start
Settings