Skip to content

Instantly share code, notes, and snippets.

@naviocean
Forked from AnatomicJC/zfs-docker.md
Created November 14, 2022 15:09
Show Gist options
  • Save naviocean/4f5c2f4901fdd3b3eb624c803b65fb87 to your computer and use it in GitHub Desktop.
Save naviocean/4f5c2f4901fdd3b3eb624c803b65fb87 to your computer and use it in GitHub Desktop.
ZFS and Docker

Create a dedicated ZFS docker pool with deduplication disabled in case of dedup enabled on your system:

zfs create -o mountpoint=/var/lib/docker -o dedup=off rpool/docker

Sometimes, you don't want ZFS for docker storage. ZFS can be sadly quite painful with Docker in Docker and similar scenarios. It might be best to avoid the problem by creating a volume in your ZFS pool, formatting that volume to ext4, and having docker use "overlay2" on top of that, instead of "zfs".

zfs create -s -V 30G rpool/docker
mkfs.ext4 /dev/zvol/rpool/docker
tune2fs -o journal_data_writeback /dev/zvol/rpool/docker
mount /dev/zvol/rpool/docker /var/lib/docker

Add the mount to /etc/fstab:

$ cat /etc/fstab
/dev/zvol/rpool/docker /var/lib/docker	ext4 noatime,data=writeback,barrier=0,nobh,errors=remount-ro 0 1

Ref:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment