Config folder of nextcloud docker container got changed permissions after every restart

Nextcloud version: 25.0.3
Docker version: 20.10.22
Operating system and version Fedora 37

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:
None

The output of your Nextcloud log in Admin > Logging:


0. /var/www/html/lib/private/Config.php line 143
   OC\Config->writeData()
1. /var/www/html/lib/private/SystemConfig.php line 146
   OC\Config->setValue("instanceid", "ocmlogr17dul")
2. /var/www/html/lib/private/legacy/OC_Util.php line 900
   OC\SystemConfig->setValue("instanceid", "ocmlogr17dul")
3. /var/www/html/lib/base.php line 430
   OC_Util::getInstanceId()
4. /var/www/html/lib/base.php line 676
   OC::initSession()
5. /var/www/html/lib/base.php line 1144
   OC::init()
6. /var/www/html/remote.php line 119
   require_once("/var/www/html/lib/base.php")

PROPFIND /remote.php/dav/addressbooks/users/huddeij/contacts/
from 172.24.0.1 at 2023-01-24T11:34:17+00:00

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 =>
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'instanceid' => 'xxxxxxxxxxxx',
  'passwordsalt' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  'trusted_domains' =>
  array (
    0 => 'nc.example.com',
    1 => '192.168.0.28',
    2 => '172.24.0.3',
  ),
  'trusted_proxies' => '172.17.0.5',
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '25.0.3.2',
  'overwrite.cli.url' => 'http://nc.example.com',
  'dbname' => 'nextcloud',
  'dbhost' => 'db',
  'overwritehost ' => '192.168.0.28',
  'overwriteprotocol' => 'https',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'huddeij',
  'dbpassword' => 'xxxxxxxxxxxxxxx',
  'default_phone_region' => 'de',
  'installed' => true,
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'tls',
  'mail_sendmailmode' => 'smtp',
  'mail_smtpport' => '587',
  'mail_smtphost' => 'mail.gmx.net ',
  'mail_from_address' => 'user',
  'mail_domain' => 'mail.com',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'user@mail.com',
  'mail_smtppassword' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  'twofactor_enforced' => 'false',
  'loglevel' => 2,
  'maintenance' => false,
);

The output of your Apache/nginx/system log in /var/log/____:
no clue where to find

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

{"reqId":"hL59mhEjL2HfandnZ9e2","level":3,"time":"2023-01-24T11:34:17+00:00","remoteAddr":"172.24.0.1","user":"--","app":"remote","method":"PROPFIND","url":"/remote.php/dav/addressbooks/users/user/contacts/","message":"Configuration was not read or initialized correctly, not overwriting /var/www/html/config/config.php","userAgent":"DAVx5/4.2.6-ose (2022/12/12; dav4jvm; okhttp/4.10.0) Android/12","version":"","exception":{"Exception":"OCP\\HintException","Message":"Configuration was not read or initialized correctly, not overwriting /var/www/html/config/config.php","Code":0,"Trace":[{"file":"/var/www/html/lib/private/Config.php","line":143,"function":"writeData","class":"OC\\Config","type":"->","args":[]},{"file":"/var/www/html/lib/private/SystemConfig.php","line":146,"function":"setValue","class":"OC\\Config","type":"->","args":["instanceid","xxxxxxxxxxxx"]},{"file":"/var/www/html/lib/private/legacy/OC_Util.php","line":900,"function":"setValue","class":"OC\\SystemConfig","type":"->","args":["instanceid","xxxxxxxxxxxx"]},{"file":"/var/www/html/lib/base.php","line":430,"function":"getInstanceId","class":"OC_Util","type":"::","args":[]},{"file":"/var/www/html/lib/base.php","line":676,"function":"initSession","class":"OC","type":"::","args":[]},{"file":"/var/www/html/lib/base.php","line":1144,"function":"init","class":"OC","type":"::","args":[]},{"file":"/var/www/html/remote.php","line":119,"args":["/var/www/html/lib/base.php"],"function":"require_once"}],"File":"/var/www/html/lib/private/Config.php","Line":266,"Hint":"Configuration was not read or initialized correctly, not overwriting /var/www/html/config/config.php","message":"Configuration was not read or initialized correctly, not overwriting /var/www/html/config/config.php","exception":{},"CustomMessage":"Configuration was not read or initialized correctly, not overwriting /var/www/html/config/config.php"}}

The permissions of Nextcloud’s config folder (including all files) get switched after restart from “33:tape” (outside the container) respectively www-data:www-data inside the container to “myusername:myusergroup”. I can’t sort out why.

I have to write
sudo docker exec nextcloud-app chown -R www-data:www-data /var/www/html/config
or
sudo chown -R 33:tape /volume1/docker/Nextcloud/config
on a daily basis to not getting erros on davx and the website.

The affected volume in the docker-compose file looks like this:

  • /volume1/docker/Nextcloud/config:/var/www/html/config

The config ls -la output:

drwxr-xr-x 15   33 tape  4096 23. Jan 11:18 .
drwxr-xr-x 21 root root  4096 25. Jan 14:07 ..
drwxr-xr-x 47   33 tape  4096 23. Jan 11:18 3rdparty
drwxr-xr-x 50   33 tape  4096  8. Jan 16:02 apps
-rw-r--r--  1   33 tape 19327 23. Jan 11:18 AUTHORS
drwxr-xr-x 2 1000 911 4096 Jan 8 15:02 config
-rw-r--r--  1   33 tape  4095 23. Jan 11:18 console.php
-rw-r--r--  1   33 tape 34520 23. Jan 11:18 COPYING
drwxr-xr-x 23   33 tape  4096 23. Jan 11:18 core
-rw-r--r--  1   33 tape  6317 23. Jan 11:18 cron.php
drwxr-xr-x  6   33 tape  4096  8. Jan 16:05 custom_apps
drwxrwx---  6   33 tape  4096  8. Jan 18:40 data
drwxr-xr-x  2   33 tape 12288 23. Jan 11:18 dist
-rw-r--r--  1   33 tape  4385 23. Jan 11:18 .htaccess
-rw-r--r--  1   33 tape   156 23. Jan 11:18 index.html
-rw-r--r--  1   33 tape  3456 23. Jan 11:18 index.php
drwxr-xr-x  6   33 tape  4096 23. Jan 11:18 lib
-rwxr-xr-x  1   33 tape   283 23. Jan 11:18 occ
drwxr-xr-x  2   33 tape  4096 23. Jan 11:18 ocm-provider
drwxr-xr-x  2   33 tape  4096 23. Jan 11:18 ocs
drwxr-xr-x  2   33 tape  4096 23. Jan 11:18 ocs-provider
-rw-r--r--  1   33 tape  3139 23. Jan 11:18 public.php
-rw-r--r--  1   33 tape  5549 23. Jan 11:18 remote.php
drwxr-xr-x  4   33 tape  4096 23. Jan 11:18 resources
-rw-r--r--  1   33 tape    26 23. Jan 11:18 robots.txt
-rw-r--r--  1   33 tape  2452 23. Jan 11:18 status.php
drwxr-xr-x  3   33 tape  4096  8. Jan 16:02 themes
-rw-r--r--  1   33 tape   101 23. Jan 11:18 .user.ini
-rw-r--r--  1   33 tape   383 23. Jan 11:18 version.php

pwd of config folder: /volume1/docker/Nextcloud/config

What I tried:

  • tried to change it to www-data:www-data by exec chown command inside the docker container. worked until restart or random (difference of days) permission change
  • tried to change it to (as shown inside the other files and folders of the nextcloud folder) 33:tape per chown command outside the container. worked until restart or random (difference of days) permission change

This question is better suited to docker community. Check your user permissions for docker as a user group on the system. Also post your permissions with ls -la or similar so others can see exactly what is happening. Consider filling out the support template with logs.

Hi @Huddeij,
You are missing the required support template. Please fill this form out and edit into your post.

This will give us the technical info and logs needed to help you! Thanks.

See Step 2 Executing the Docker Command Without Sudo (Optional)

Tried to change it as much as possible