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

Hi,
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:

Failure
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'

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

services:
  db:
    image: mariadb:10.6
    restart: always
    command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
    volumes:
      - database:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud

  app:
    image: nextcloud
    restart: always
    ports:
      - 8001:80
    links:
      - db
    volumes:
      - data:/var/www/html
    environment:
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=db

My TrueNAS Scale Setup:
Main Dataset:
/mnt/main/nextcloud
Permissions:
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 Type: SMB/NFSv4
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 @anon63365167 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.