Nextcloud Docker Permission Error for data directory

I run nextcloud together with mariadb in a docker container. This kind of problem is often discussed with native nextcloud installations, but not with docker container.

My docker-compose.yml looks like this:

version: '2'


    image: mariadb:latest
    container_name: nextcloud-db
    restart: always
    hostname: nextcloud-db
      MYSQL_ROOT_PASSWORD: s3cr3t_NCpw
      MYSQL_DATABASE: ncdb
      MYSQL_USER: nextcloud-dbuser
      MYSQL_PASSWORD: s3cr3t_NCpw
      - /srv/docker-persist/MariaDB/nextcloud-sql:/var/lib/mysql

    image: nextcloud:stable
    container_name: nextcloud
    restart: unless-stopped
      - 80:80
      - /srv/docker-persist/Nextcloud:/var/www/html
      - /mnt/NC/containers/cloud/nextcloud/data:/var/www/html/data
      - nextcloud-db

Obviously i want to use an external storage, which is mounted at /mnt/NC, as my data directory.
My /etc/fstab is this:
UUID=D24E7C0D4E7BE89D /mnt/NC/ ntfs-3g utf8,dmask=007,fmask=007,umask=007,noatime 0

A few weeks ago i run nextcloud native on my system WITHOUT docker, and this fstab works perfectly with nextcloud - sure, i had UID/GID www-data inside fstab, but this one is missing, cause nextcloud is running inside docker - i think here is the Problem.

So there is no www-data user/group on my system ONLY in my docker container.
I already changed the permission for /mnt/NC to 755.
drwxrwx--- 1 root root 4096 18. Jul 16:51 NC

Changing the user/group dont work - sure, because there is no www-data on my system:
chown -R www-data:www-data /mnt/NC
chown: invalid user: „www-data:www-data“

Inside my docker container, the permission looks like this:

-rw-r--r--  1 www-data www-data  5048 Jul 18 14:44 cron.php
drwxr-xr-x  2 www-data www-data  4096 Jul 18 14:44 custom_apps
drwxrwx---  1 root     root      4096 Jul 18 14:21 data
-rw-r--r--  1 www-data www-data   156 Jul 18 14:44 index.html
-rw-r--r--  1 www-data www-data  2976 Jul 18 14:44 index.php

You can see, data is root:root. Changing the user/group to www-data has no effect:
chown -R www-data:www-data ./data/
drwxrwx--- 1 root root 4096 Jul 18 14:21 data

All in all, i’ll get the error message inside the web interface:

The data directory / var / www / html / data cannot be created or cannot be written to.

So… whats next?

Mounting /mnt/NC with uid and gid 33 on host solved the problem. On my host, 33 belongs to user http and in the nextcloud docker 33 belongs to www-data. Weird, but fixable.

nope. work’s as designed. :wink:

Oh, well, when I read all the open issues on Github regarding UID / GID at the nextcloud docker with some missing parameters …