Issue Description
I have nextcloud install on an Ubuntu server via docker compose. It was working well for a few hours.
After configuring a few things, I’ve moved (mv
) the nextcloud (or /var/www/html) folder from the Server to a separate Synology NAS which is mounted on the Server.
When I did this, I started getting folder permission issues. I have been trying a few chmod/chown options but I haven’t been able to solve it yet.
Error Message
Cannot write into "apps" directory.
This can usually be fixed by giving the web server write access to the apps directory or disabling the App Store in the config file.
Your data directory is not writable.
Permissions can usually be fixed by giving the web server write access to the root directory. See https://docs.nextcloud.com/server/25/go.php?to=admin-dir_permissions.
The error clearly looks like a permission issue of the apps and data folder, which I think it’s an overall issue of the nextcloud volume mounted, but I am unable to fix it.
What permissions do I need to add? Do I need to add them inside the docker container (i.e. volume), on the Ubuntu Server mount or on the NAS directory?
Note: the link at the end of the error seems broken.
Troubleshooting
I have tried the following commands on the Ubuntu server (each group represents a round of testing):
$ sudo chown -R root:root /mnt/nas/Data/Nextcloud
$ sudo chmod 0770 /mnt/nas/Data/Nextcloud
$ sudo chown -R www-data:www-data /mnt/nas/Data/Nextcloud
$ sudo chmod 0770 /mnt/nas/Data/Nextcloud
$ sudo chown -R www-data:www-data /mnt/nas/Data/Nextcloud
$ sudo find /mnt/nas/Data/Nextcloud -type d -exec chmod 750 {} \;
$ sudo find nextcloud/ -type f -exec chmod 640 {} \;
None of them seemed to work. I would normally restar the container after running them (docker-compose down && docker-compose up -d
).
Documentation
docker-compose.yaml
version: "2"
services:
app:
container_name: nextcloud
image: nextcloud
restart: unless-stopped
volumes:
- ./data/config:/var/www/html/config
- /mnt/nas/Data/Nextcloud/html:/var/www/html
env_file:
- ./secrets.env
- config directory works fine.
- /mnt/nas/Data/Nextcloud/html is a mounted directory on the Ubuntu Server from the Synology NAS. When this folder was on ./data/nextcloud things worked fine.
The directory is mounted via fstab
(cifs):
//192.168.250.200/Data /mnt/nas/Data cifs credentials=/etc/samba/nas_passwd_file,rw,uid=1000 0 0
config.php
<?php
$CONFIG = [
'htaccess.RewriteBase' => '/',
'memcache.local' => '\\OC\\Memcache\\APCu',
'apps_paths' => [
0 => [
'path' => '/var/www/html/apps',
'url' => '/apps',
'writable' => true,
],
1 => [
'path' => '/var/www/html/custom_apps',
'url' => '/custom_apps',
'writable' => true,
],
],
'memcache.distributed' => '\\OC\\Memcache\\Redis',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'redis' => [
'host' => '<redacted>',
'password' => '<redacted>',
'port' => 6379,
],
'instanceid' => '<redacted>',
'passwordsalt' => '<redacted>',
'secret' => '<redacted>',
'trusted_domains' => [
0 => '<redacted>',
],
'datadirectory' => '/var/www/html/data',
'dbtype' => 'pgsql',
'version' => '25.0.2.3',
'overwrite.cli.url' => '<redacted>',
'overwriteprotocol' => 'https',
'overwritehost' => '<redacted>',
'dbname' => 'nextcloud',
'dbhost' => '<redacted>',
'dbport' => '',
'dbtableprefix' => 'oc_',
'dbuser' => '<redacted>',
'dbpassword' => '<redacted>',
'installed' => true,
];
$ docker exec nextcloud ls -l /var/www/html/
drwxr-xr-x 2 1000 root 0 Jan 18 19:02 3rdparty
-rwxr-xr-x 1 1000 root 19327 Jan 18 19:02 AUTHORS
-rwxr-xr-x 1 1000 root 34520 Jan 18 19:02 COPYING
drwxr-xr-x 2 1000 root 0 Jan 15 12:04 apps
drwxr-x--- 2 www-data www-data 4096 Feb 4 12:51 config
-rwxr-xr-x 1 1000 root 4095 Jan 18 19:02 console.php
drwxr-xr-x 2 1000 root 0 Jan 18 19:02 core
-rwxr-xr-x 1 1000 root 6317 Jan 18 19:02 cron.php
drwxr-xr-x 2 1000 root 0 Feb 4 13:17 custom_apps
drwxr-xr-x 2 1000 root 0 Feb 4 13:18 data
drwxr-xr-x 2 1000 root 0 Jan 18 19:02 dist
-rwxr-xr-x 1 1000 root 156 Jan 18 19:02 index.html
-rwxr-xr-x 1 1000 root 3456 Jan 18 19:02 index.php
drwxr-xr-x 2 1000 root 0 Jan 18 19:02 lib
-rwxr-xr-x 1 1000 root 283 Jan 18 19:02 occ
drwxr-xr-x 2 1000 root 0 Jan 18 19:02 ocm-provider
drwxr-xr-x 2 1000 root 0 Jan 18 19:02 ocs
drwxr-xr-x 2 1000 root 0 Jan 18 19:02 ocs-provider
-rwxr-xr-x 1 1000 root 3139 Jan 18 19:02 public.php
-rwxr-xr-x 1 1000 root 5549 Jan 18 19:02 remote.php
drwxr-xr-x 2 1000 root 0 Jan 18 19:02 resources
-rwxr-xr-x 1 1000 root 26 Jan 18 19:02 robots.txt
-rwxr-xr-x 1 1000 root 2452 Jan 18 19:02 status.php
drwxr-xr-x 2 1000 root 0 Feb 4 13:18 themes
-rwxr-xr-x 1 1000 root 383 Jan 18 19:02 version.php
ls -l /mnt/nas/Data/Nextcloud/html/
drwxr-xr-x 2 nito root 0 Jan 19 03:02 3rdparty
-rwxr-xr-x 1 nito root 19327 Jan 19 03:02 AUTHORS
-rwxr-xr-x 1 nito root 34520 Jan 19 03:02 COPYING
drwxr-xr-x 2 nito root 0 Jan 15 20:04 apps
drwxr-xr-x 2 nito root 0 Jan 15 20:04 config
-rwxr-xr-x 1 nito root 4095 Jan 19 03:02 console.php
drwxr-xr-x 2 nito root 0 Jan 19 03:02 core
-rwxr-xr-x 1 nito root 6317 Jan 19 03:02 cron.php
drwxr-xr-x 2 nito root 0 Feb 4 21:17 custom_apps
drwxr-xr-x 2 nito root 0 Feb 4 21:18 data
drwxr-xr-x 2 nito root 0 Jan 19 03:02 dist
-rwxr-xr-x 1 nito root 156 Jan 19 03:02 index.html
-rwxr-xr-x 1 nito root 3456 Jan 19 03:02 index.php
drwxr-xr-x 2 nito root 0 Jan 19 03:02 lib
-rwxr-xr-x 1 nito root 283 Jan 19 03:02 occ
drwxr-xr-x 2 nito root 0 Jan 19 03:02 ocm-provider
drwxr-xr-x 2 nito root 0 Jan 19 03:02 ocs
drwxr-xr-x 2 nito root 0 Jan 19 03:02 ocs-provider
-rwxr-xr-x 1 nito root 3139 Jan 19 03:02 public.php
-rwxr-xr-x 1 nito root 5549 Jan 19 03:02 remote.php
drwxr-xr-x 2 nito root 0 Jan 19 03:02 resources
-rwxr-xr-x 1 nito root 26 Jan 19 03:02 robots.txt
-rwxr-xr-x 1 nito root 2452 Jan 19 03:02 status.php
drwxr-xr-x 2 nito root 0 Feb 4 21:18 themes
-rwxr-xr-x 1 nito root 383 Jan 19 03:02 version.php
docker exec -ti nextcloud tail data/nextcloud.log
{"reqId":"lJ9OOmhf80hAVz4xHLf4","level":3,"time":"2023-02-04T08:50:16+00:00","remoteAddr":"10.0.32.1","user":"nitobuendia","app":"PHP","method":"GET","url":"/apps/notes/notes/dashboard","message":"Undefined variable $folder at /var/www/html/custom_apps/notes/lib/Service/NoteUtil.php#154","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36","version":"25.0.3.2","exception":{"Exception":"Error","Message":"Undefined variable $folder at /var/www/html/custom_apps/notes/lib/Service/NoteUtil.php#154","Code":0,"Trace":[{"file":"/var/www/html/custom_apps/notes/lib/Service/NoteUtil.php","line":154,"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::","args":[2,"Undefined variable $folder","/var/www/html/custom_apps/notes/lib/Service/NoteUtil.php",154]},{"file":"/var/www/html/custom_apps/notes/lib/Service/NotesService.php","line":153,"function":"getOrCreateFolder","class":"OCA\\Notes\\Service\\NoteUtil","type":"->","args":["/nitobuendia/files/Notes",false]},{"file":"/var/www/html/custom_apps/notes/lib/Service/NotesService.php","line":30,"function":"getNotesFolder","class":"OCA\\Notes\\Service\\NotesService","type":"->","args":["nitobuendia",false]},{"file":"/var/www/html/custom_apps/notes/lib/Service/NotesService.php","line":46,"function":"getAll","class":"OCA\\Notes\\Service\\NotesService","type":"->","args":["nitobuendia"]},{"file":"/var/www/html/custom_apps/notes/lib/Controller/NotesController.php","line":101,"function":"getTopNotes","class":"OCA\\Notes\\Service\\NotesService","type":"->","args":["nitobuendia"]},{"file":"/var/www/html/custom_apps/notes/lib/Service/Util.php","line":26,"function":"OCA\\Notes\\Controller\\{closure}","class":"OCA\\Notes\\Controller\\NotesController","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/html/custom_apps/notes/lib/Controller/Helper.php","line":140,"function":"retryIfLocked","class":"OCA\\Notes\\Service\\Util","type":"::","args":[{"__class__":"Closure"}]},{"file":"/var/www/html/custom_apps/notes/lib/Controller/NotesController.php","line":122,"function":"handleErrorResponse","class":"OCA\\Notes\\Controller\\Helper","type":"->","args":[{"__class__":"Closure"}]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":225,"function":"dashboard","class":"OCA\\Notes\\Controller\\NotesController","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":133,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Notes\\Controller\\NotesController"},"dashboard"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":172,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Notes\\Controller\\NotesController"},"dashboard"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":298,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Notes\\Controller\\NotesController","dashboard",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},["notes.notes.dashboard"]]},{"file":"/var/www/html/lib/base.php","line":1047,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/apps/notes/notes/dashboard"]},{"file":"/var/www/html/index.php","line":36,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"}}
Version Information
Nextcloud version: 25.0. 3
Operating system and version (eg, Ubuntu 20.04): Ubuntu 22.04.1 LTS