I'm trying to setup some dockerised NAS, with mergerfs and samba:
services:
mergerfs:
build: ./mergerfs # just debian and install latest release
cap_add:
- SYS_ADMIN
devices:
- /dev/fuse:/dev/fuse
volumes:
- media:/mnt/pool
- /mnt/data0:/mnt/data0
...
...
samba:
image: dperson/samba
command: -s'media;/srv/media;yes;no;yes' # guest allowed, not RO
volumes:
- media:/srv/media
depends_on:
- mergerfs
...
volumes:
media:
The problem is that, while I can read/write to /srv/media
on samba
, it doesn't get through to /mnt/pool
on mergerfs
.
(I can see this by watching docker-compose logs mergerfs
while doing docker-compose exec samba sh -c "echo 'foobar' > /srv/media/test.txt"
which shows nothing in logs, versus the equivalent exec mergerfs
which does.)
How can I make this named volume media
be a mere 'proxy' for the actual filesystem provided by the mergerfs
service?
The answer lies in bind propagation.
In particular, here mergerfs needs
media
to be atype:bind
rather thantype:volume
, so that it can be set to have (recursively) (r
)shared
bind propagation - which means that mounts configured by the container will be propagated back to the host.That is,
media:/mnt/pool
becomes/mnt/media:/mnt/pool:rshared
.