Trouble with installing Nextcloud with docker compose and storing all data on TrueNAS Scale NAS

for the past few days I’ve been trying to get the following setup to work:

Nextcloud installation in docker on a server.
Store all of Nextclouds data in a different server running TrueNAS Scale.

The problem:
Everytime I try to deploy the Nextcloud stack I get an error message. Here is the full message:

failed to deploy a stack: Network nextcloud_default Creating Network nextcloud_default Created Volume “nextcloud_database” Creating Volume “nextcloud_database” Created Volume “nextcloud_data” Creating Volume “nextcloud_data” Created Container nextcloud-db-1 Creating Error response from daemon: failed to chmod on /mnt/dietpi_userdata/docker-data/volumes/nextcloud_database/_data: chmod /mnt/dietpi_userdata/docker-data/volumes/nextcloud_database/_data: operation not permitted

Here is the docker compose file I am using:

version: '2'

    driver: local
      type: "nfs"
      o: "addr=,rw,noatime,tcp,timeo=20,nfsvers=4"
      device: ":/mnt/main/nextcloud/database"
    driver: local
      type: "nfs"
      o: "addr=,rw,noatime,rsize=8192,wsize=8192,tcp,timeo=20,nfsvers=4"
      device: ":/mnt/main/nextcloud/data"

    image: mariadb:10.6
    restart: always
    command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
      - database:/var/lib/mysql
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud

    image: nextcloud
    restart: always
      - 8001:80
      - db
      - data:/var/www/html
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=db

My TrueNAS Scale Setup:
Main Dataset:
Owner / Group: root
All permissions are granted except for write permissions for group and other

Nextcloud Data (/mnt/main/nextcloud/data) and Database (/mnt/main/nextcloud/database) Dataset settings:
Owner / Group: root
All permissions are granted to everyone
ACL Mode: Passthrough

NFS Settings:
Enable NFSv4: On
NFSv3 ownership model for NFSv4: Off
Everything else if off / empty

I tried to create / delete files in my data and dataset shares with a seperate container and it worked. However Nextcloud seems to have a problem with permissions and I am not able to find a solution.

hi @Cubic welcome to the forum :handshake:

the error pretty clear shows there is some issue access/change permissions while mounting docker volume…

Independent from the actual error - are you sure you really want to store your NC data remotely? There might be good reasons to do so but in general I would recommend to store data locally and backup to the remote NAS system for the sake of simplicity… Keeping everything in one place reduce complexity and simplifies troubleshooting.

bte: TrueNAS is capable of running docker containers natively - maybe this is a more robust solution?

Thank you for your answer.

I can’t store any data locally because the computer Nextcloud runs on doesn’t have enough storage space.

I originally wanted to install Nextcloud on TrueNAS Scale but I wasn’t able figure out how to access Nextcloud through a vpn (Tailscale) from there. I am able to access the TrueNAS web interface through the vpn but I am not able to access Nextcloud for some reason.

If I cant get this setup to run ill probably install Nextcloud on my NAS System again and make a Cloudflare Tunnel to that machine. Even though this would be the most practical solution, this would expose Nextcloud to the whole Internet which is something I originally wanted to avoid.