Skip to content

Instantly share code, notes, and snippets.

@AnatomicJC
Last active December 14, 2023 00:33
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save AnatomicJC/897e0e65973df1a777427ad9c1c6f0e3 to your computer and use it in GitHub Desktop.
Save AnatomicJC/897e0e65973df1a777427ad9c1c6f0e3 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:

@mraaroncruz
Copy link

🙏

@AnatomicJC
Copy link
Author

You're welcome man

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