NC 18 in docker with data folder on Synology NFS

My issue is similar to this one I think. I try to user Synology NFS as data folder for my Nextcloud docker container. I what I’ve got so far:
When I start initial setup it reports that data folder is not writable which is related to the issue I mentioned. In lib/Setup.php I’ve found !is_writable($dataDir)) which is not reliable check as stated in one of comments of the issue. When I commented out this check in the file I got set up running but failed shortly with another error:

Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.

It seems that the initial set up is not able to create folders inside user’s dir (the directory data/username/files/ has been created successfully though). When I issue php occ files:scan-app-data it fails with errors:

An unhandled exception has been thrown:
RuntimeException: Could not get appdata folder for text in /var/www/html/lib/private/Files/AppData/AppData.php:119
Stack trace:
#0 /var/www/html/lib/private/Files/AppData/AppData.php(158): OC\Files\AppData\AppData->getAppDataFolder()
#1 /var/www/html/apps/text/lib/Service/DocumentService.php(114): OC\Files\AppData\AppData->newFolder('documents')
#2 [internal function]: OCA\Text\Service\DocumentService->__construct(Object(OCA\Text\Db\DocumentMapper), Object(OCA\Text\Db\StepMapper), Object(OC\Files\AppData\AppData), NULL, Object(OC\Files\Node\LazyRoot), Object(OC\Memcache\Factory), Object(OC\AppFramework\Logger), Object(OC\Share20\Manager), Object(OC\AppFramework\Http\Request), Object(OC\DirectEditing\Manager), Object(OC\Lock\DBLockingProvider))
#3 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(83): ReflectionClass->newInstanceArgs(Array)
#4 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(100): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))
#5 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(115): OC\AppFramework\Utility\SimpleContainer->resolve('OCA\\Text\\Servic...')
#6 /var/www/html/lib/private/AppFramework/DependencyInjection/DIContainer.php(415): OC\AppFramework\Utility\SimpleContainer->query('OCA\\Text\\Servic...')
#7 /var/www/html/lib/private/AppFramework/DependencyInjection/DIContainer.php(386): OC\AppFramework\DependencyInjection\DIContainer->queryNoFallback('OCA\\Text\\Servic...')
#8 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(70): OC\AppFramework\DependencyInjection\DIContainer->query('OCA\\Text\\Servic...', true)
#9 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(100): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))
#10 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(115): OC\AppFramework\Utility\SimpleContainer->resolve('OCA\\Text\\Comman...')
#11 /var/www/html/lib/private/AppFramework/DependencyInjection/DIContainer.php(415): OC\AppFramework\Utility\SimpleContainer->query('OCA\\Text\\Comman...')
#12 /var/www/html/lib/private/ServerContainer.php(134): OC\AppFramework\DependencyInjection\DIContainer->queryNoFallback('OCA\\Text\\Comman...')
#13 /var/www/html/lib/private/Console/Application.php(220): OC\ServerContainer->query('OCA\\Text\\Comman...')
#14 /var/www/html/lib/private/Console/Application.php(135): OC\Console\Application->loadCommandsFromInfoXml(Array)
#15 /var/www/html/console.php(98): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /var/www/html/occ(11): require_once('/var/www/html/c...')

But when I am able to create files and directories inside the user’s dir with www-data user:

user@nextcloud:~/nextcloud$ docker exec -it --user www-data nextcloud sh
$ mkdir data/d_speranskiy/files/test
$ ls data/d_speranskiy/files
test
$ rm -r data/d_speranskiy/files/test
rm: remove write-protected directory 'data/d_speranskiy/files/test'? y
$ 

What could be wrong here? Is it a bug and do I have to create an issue on github?

I’ve finished initial setup unmounting NFS share from data and the moved created files back to NFS share:

user@nextcloud:~$ docker exec -it --user www-data nextcloud sh
$ php occ files:scan --path "d_speranskiy/files"
Starting scan for user 1 out of 1 (d_speranskiy)
Home storage for user d_speranskiy not writable
Make sure you're running the scan command only as the user the web server runs as
+---------+-------+--------------+
| Folders | Files | Elapsed time |
+---------+-------+--------------+
| 0       | 0     | 00:00:00     |
+---------+-------+--------------+
$ ls -lah data
total 52K
drwxrwxrwx  5 www-data www-data 4.0K Mar 17 15:55 .
drwxr-xr-x 14 www-data root     4.0K Mar 17 15:38 ..
-rwxrwxrwx  1 www-data www-data  542 Mar 17 10:32 .htaccess
-rwxrwxrwx  1 www-data www-data    0 Mar 17 10:32 .ocdata
-rwxrwxrwx  1 www-data www-data  101 Mar 17 09:33 .user.ini
drwxrwxrwx  9 www-data www-data 4.0K Mar 17 15:43 appdata_oc7xv0asqx56
drwxrwxrwx  5 www-data www-data 4.0K Mar 17 15:49 d_speranskiy
drwxrwxrwx  2 www-data www-data 4.0K Mar 17 15:40 files_external
-rwxrwxrwx  1 www-data www-data    0 Mar 17 15:39 index.html
-rwxrwxrwx  1 www-data www-data  24K Mar 17 15:51 nextcloud.log
$ ls -lah data/d_speranskiy
total 20K
drwxrwxrwx 5 www-data www-data 4.0K Mar 17 15:49 .
drwxrwxrwx 5 www-data www-data 4.0K Mar 17 15:55 ..
drwxrwxrwx 2 www-data www-data 4.0K Mar 17 15:48 cache
drwxrwxrwx 4 www-data www-data 4.0K Mar 17 15:52 files
drwxrwxrwx 2 www-data www-data 4.0K Mar 17 15:49 uploads

What am I doing wrong?

you try to do something you shouldn’t.
first rule: never shell into your container and do something.

e.g. it’s

docker exec --user www-data nextcloud php occ files:scan --path "d_speranskiy/files"

so. what is your setup? running the container on your synology or on a server next to it? what is your docker-compose file? how did you setup the container? did you mount the nfs share on your host and use it as a volume or did you mount the nfs share “in” your container?

I try to run nextcloud on a server and mount Synology NFS share. I’ve tried both variants-:

  1. mount nfs to the host and then mount it unside docker cintainer
  2. mount NFS to a docker named volume.
    The results are the same. I’m able to create files in directories on the mounted nfs share but NC is not. www-data user’s UID on nfs server and inside containers are the same…

sorry. never tried this.

but you can use a nfs share directly as a docker volume. did you try this?

Yes, I meant it under variant #2, sorry for bad description. Plus I don’t use docker-compose or docker swarm. I just create a volume and then the docker container with the volume mounted to /var/www/html/data

I’ve started from scratch, recreated NFS share on Synology, granted permissions properly, created user with the same uid (nothing extra I havn’t done earlier though) and now it’s up and running properly for some reason. So it seems it was permissions issue on the synology side.

Speranskiy,

Im trying to accomplisch theexact same thing could you explain me how you did this.
Im getting all kinds of permission issues. Wat did you set as permissions on the synology side?

greets.

thaks

Sono

Hi Speranskly,

I have been hitting a wall with this exact same issue. Are you able to write a brief breakdown of the steps you took?

I have recreated my share but am guessing im getting something wrong in the granting of permissions and UID setup. Id love to hear what you did to see if i can repicate it!

Sorry, guys. It’s almost 1 year old thread. And I don’t use Synology as a storage backend any more (unbearable slow). I cant remember details you’re asking for.

No worries, thanks for the reply. Ill keep tapping keys and hopefully i get somewhere!