Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config.php not updating after image rebuild #464

Closed
sseeland opened this issue Sep 14, 2018 · 16 comments
Closed

config.php not updating after image rebuild #464

sseeland opened this issue Sep 14, 2018 · 16 comments
Labels
enhancement feature: auto config (environment variables) Auto configuring via environment variables needs review Needs confirmation this is still happening or relevant

Comments

@sseeland
Copy link

I want to change a setting in my config.php. I'm following this example: https://github.com/nextcloud/docker/tree/master/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/app
so my dockerfile copies my config file (misc.config.php) into /usr/src/nextcloud/config/.

This works perfectly well when I initialize the service for the first time. Nextcloud somehow merges all the *.config.php files into config.php, which gets copied to the /var/www/html/ volume and all is well. However, when I change my misc.config.php file and rebuild the image, nothing happens. The file arrives safely in /usr/src/nextcloud/config/ but the change never propagates to /var/www/html/.

Am I missing something? Shouldn't this be automatic?

@bitdegree67
Copy link

same problem here. i want to add redis in /usr/src/nextcloud/config/redis.config.php after first image creation. but php occ config:list don't show redis config. it's normal ?

@SnowMB
Copy link
Contributor

SnowMB commented Sep 19, 2018

Yes, this is normal behaviour.

The /usr/src/nextcloud/... directory will only be used to copy data if the nextcloud version inside that directory is greater than the installed nextcloud in /var/www/html. Secondly we exclude the existing directories config data custom_apps themes on updates. Your additions to the Dockerfile will only be propagated on new instances.

For existing instances you don't have to alter your Dockerfile. Just copy the new file into your (persistent) volume. For example:

docker cp redis.config.php CONTAINER:/var/www/html/config/redis.config.php

@hno
Copy link

hno commented Jan 4, 2019

I think there needs to be a separate path for image provided config files, separate from the user configuration. As a user you normally only touch config.php, and it's very confusing that "static" config files differ depending on when the installation was initially done, resulting in different behavior even if one is using the exact same versions and config.php.
As a safety guard, if the same file exists in config/ then it should override the image provided one.
This likely require support from NextCloud to have a config path list.

@unbranched
Copy link

unbranched commented Feb 13, 2019

I have some difficulties to understand this. It looks like Redis isn't used by my nextcloud-apache container.
Here is my docker-compose.yml:

version: '3.5'

volumes:
  nextcloud:
  db:

services:
  redis:
    image: redis:alpine
    restart: always

  app:
    image: nextcloud:${NEXTCLOUD_VERSION}
    restart: always
    ports:
      - ${HTTP_PORT}:80
    depends_on:
      - db
      - redis
    environment:
      - NEXTCLOUD_DOMAIN=${NEXTCLOUD_DOMAIN}
      - NEXTCLOUD_DB_TYPE=mysql
      - NEXTCLOUD_MYSQL_UTF8MB4=true
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PWD}
      - MYSQL_PASSWORD=${MYSQL_PWD}
      - MYSQL_DATABASE=${MYSQL_DB}
      - MYSQL_USER=${MYSQL_USER}
      - MYSQL_HOST=db
      - REDIS_HOST=redis
    links:
      - db
    volumes:
      - nextcloud:/var/www/html

  db:
    image: mariadb
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PWD}
      - MYSQL_PASSWORD=${MYSQL_PWD}
      - MYSQL_DATABASE=${MYSQL_DB}
      - MYSQL_USER=${MYSQL_USER}
      - MYSQL_HOST=db
      - MARIADB_MAX_ALLOWED_PACKET=128M
      - MARIADB_INNODB_LOG_FILE_SIZE=64M
    volumes:
      - db:/var/lib/mysql

Of course all variables are included in the external env file.

And this is the resulting config/config.php file:

<?php
$CONFIG = array (
  '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' => 'ocer0rct2tum',
  'passwordsalt' => 'tfdi2j5S+VjRXTiv3dbgTaC11hyY3P',
  'secret' => '6H0dSvnM+PARFFdWRc6yZMICrOYe7a4J/L3JnmrbggjlR3Bk',
  'trusted_domains' =>
  array (
    0 => 'mydomain',
  ),
  'datadirectory' => '/var/www/html/data',
  'overwrite.cli.url' => 'http://192.168.1.15:8080',
  'dbtype' => 'mysql',
  'version' => '15.0.4.0',
  'dbname' => 'nextcloudDB',
  'dbhost' => 'db',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'test',
  'dbpassword' => 'test',
  'logtimezone' => 'UTC',
  'installed' => true,
  'maintenance' => false,
  'loglevel' => 2,
);

@marceljd
Copy link
Contributor

marceljd commented Feb 13, 2019 via email

@unbranched
Copy link

@mabkenar I just reinstalled the whole docker image using that composer.yml but Redis doesn't get automatically added to the config file.
Anyway I put it manually and now the file locking feautre works correctly, thanks for the help.

@marceljd
Copy link
Contributor

marceljd commented Feb 13, 2019

@unbranched I just tried your config file, I only replaced all variables with test. It worked, the redis config entries are in the new config.php.

<?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, ), ), 'memcache.distributed' => '\\OC\\Memcache\\Redis', 'memcache.locking' => '\\OC\\Memcache\\Redis', 'redis' => array ( 'host' => 'redis', 'port' => 6379, ), .......

I think you should try to start it with the variables in the docker-compose file first, and try to move them to an environment file as a second step. Good luck.

Edit: do not know why the formatting fails, but it is in there.....

@TheLastProject
Copy link
Contributor

TheLastProject commented Dec 4, 2022

I spent hours and hours debugging to figure out my config.php was outdated. It seems this bug also causes changes to the environment variables to not cause a configuration file update. Therefore Nextcloud's Docker container is not configurable the same way one would normally configure applications in Docker: by changing environment variables and restarting the container.

Is there at least some way to force a reconfiguration? Manually editing config.php is a very ugly workaround, I want the environment variables given to the container to be the configuration source of truth (as they are with all other Docker containers) and avoid manual changes.

@danielh186
Copy link

danielh186 commented Dec 25, 2022

@TheLastProject Did you find a solution? I am currently having the same problem. I basically tried everything. Deleting the complete container, clearing build cache etc. but nothing really helped.
I am constantly getting a weird boilerplate config.php file. All of my configurations inside the docker-compose.yml are just straight up ignored. Yesterday everything worked fine but since today its just not working anymore!

@TheLastProject
Copy link
Contributor

I ended up just manually editing config.php. I could not find any way to get Nextcloud to behave properly here.

@m-a-v
Copy link

m-a-v commented Feb 24, 2023

I suppose the problem is that the config.php file is mounted using

volumes:
      - nextcloud:/var/www/html

So, if there is a config.php the already existing the file is used. I had a similar problem that the TRUSTED_PROXIES is not respected in the config.php. Not sure whether I created the config.php file manually when I first started using Nextcloud many, many months ago.

Not sure, how to recreate the config.php file, since it should use the environment variables declared in the docker-compose.yml file.

@kifeo
Copy link

kifeo commented Mar 8, 2023

in my case, the config.php is not recreated if missing

@m-a-v
Copy link

m-a-v commented Mar 9, 2023

I suppose the config.php is only created during the initial setup. But someone would need to confirm.

@martadinata666
Copy link

imho, modifying config.php over ENV with the help of bash script (docker-entrypoint.sh) is pretty much dirty, kinda hacky way and inconsistent with nextcloud guide that encourage to directly modify config.php. The ENV only read and setup once at new installation, after that need modify manually.

@joshtrichards
Copy link
Member

Related: #1533 + #1837

@joshtrichards
Copy link
Member

OP's question was answered years ago. This issue has morphed a bit.

There are now:

There are also some potentially other topical items that those in this issue may find of interest:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature: auto config (environment variables) Auto configuring via environment variables needs review Needs confirmation this is still happening or relevant
Projects
None yet
Development

No branches or pull requests