Is it possible to bind mount nested ZFS datasets without storage pool?

Hi! I’m using incus with zfs and I create multiple ZFS datasets for different data on the host filesystem.

I would like to bind mount these mountpoints of ZFS datasets to incus containers, but I can’t get it to work.

Here are the full steps:

  1. On the host, I’ve created tank dataset and its nested datasets:

    zfs create -o canmount=off rpool/tank 
    zfs create -o mountpoint=/mnt/tank/app-data rpool/tank/app-data
    zfs create -o canmount=off rpool/tank/dbs
    zfs create -o mountpoint=/mnt/tank/dbs/mariadb rpool/tank/dbs/mariadb
    
  2. copy data to /mnt/tank

  3. bind mount tank to the container on the /mnt/tank path:

    incus config device add docker tank disk source=/mnt/tank path=/mnt/tank shift=true
    
  4. Then, from inside the container:

    incus exec docker -- su --login ubuntu
    
  5. Listing /mnt/tank, I can only see directories, no files, and the directories are all owned by root.

    tree /mnt/tank
    /mnt/tank
    ├── app-data
    └── dbs
        └── mariadb
    
    4 directories, 0 files
    
  6. But I create 1.txt in /mnt/tank, it is visible on the host.

I would like to know if it is possible to bind mount nested ZFS datasets to incus containers.

Thanks!

I believe we have recursive=true to handle some of that, but I’m not sure how well that plays with shift=true

I try it:

incus config device add docker tank disk source=/mnt/tank path=/mnt/tank shift=true recursive=true

Then I’ get it:

[violet@docker ~]$ ls -l /mnt/tank/
total 10
drwxr-xr-x 39 violet violet 39 Dec 31 12:31 app-data
drwxr-xr-x  6 root   root    6 Dec 29 11:22 dbs
drwxr-xr-x  2 root   root    2 Dec 29 11:23 files

It’s very nice. It also works with shift=true.

Thanks!