docs: limit the Compose mount to the permissions mergerfs needs

The sample enabled privileged mode in addition to passing /dev/fuse
and granting SYS_ADMIN. That exposed unrelated host devices and
capabilities to the container. Remove the blanket grant and keep the
same device, capability and propagation settings as the rootful CLI
example.

Docker's default AppArmor profile denies mount(2), so on hosts where
AppArmor is enforcing the container also needs apparmor=unconfined or
a profile that allows the FUSE mount. Say so rather than restoring
privileged mode.
This commit is contained in:
Antonio SJ Musumeci 2026-11-25 12:59:08 -05:00
parent d786081b16
commit 844e1acffd

View file

@ -135,7 +135,7 @@ docker pull ghcr.io/trapexit/mergerfs:TAG
docker run --device=/dev/fuse --cap-add=SYS_ADMIN -v /mnt/to-merge:/mnt/to-merge:rshared -v /mnt/mergerfs:/mnt/mergerfs:z,shared ghcr.io/trapexit/mergerfs:TAG -f '/mnt/to-merge/*' '/mnt/mergerfs'
```
or with docker compose
or with docker compose
```
services:
@ -143,7 +143,6 @@ services:
image: ghcr.io/trapexit/mergerfs:TAG
container_name: mergerfs
restart: unless-stopped
privileged: true
cap_add:
- SYS_ADMIN
devices:
@ -164,6 +163,11 @@ services:
relabeling?](../faq/compatibility_and_integration.md#does-mergerfs-work-with-selinux-relabeling)
* `-v /mnt/to-merge:/mnt/to-merge:rshared`: The mounts from the host
to merge within the container.
* **AppArmor enforcing hosts:** Docker's default container profile
denies `mount(2)`, so `/dev/fuse` plus `SYS_ADMIN` is not enough.
Add `security_opt: ["apparmor=unconfined"]` to the service (or
`--security-opt apparmor=unconfined` with `docker run`) or use a
custom profile that allows the FUSE mount.
### rootless container runtimes