config.php not updating after image rebuild
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?
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 ?
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
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.
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,
);
The config directory is excluded from updates. If you want to activate Redis on an existing installation you have to copy the content of redis.config.php into your config.php file. You only have to copy the content lines. After that you can restart apache and it will work with your compose file.
Sent from MailDroid
-----Original Message----- From: unbranched [email protected] To: nextcloud/docker [email protected] Cc: Subscribed [email protected] Sent: wo, 13 feb. 2019 10:49 Subject: Re: [nextcloud/docker] config.php not updating after image rebuild (#464)
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, );
-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/nextcloud/docker/issues/464#issuecomment-463131788
@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.
@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.....
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.
@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!
I ended up just manually editing config.php. I could not find any way to get Nextcloud to behave properly here.
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.
in my case, the config.php is not recreated if missing
I suppose the config.php is only created during the initial setup. But someone would need to confirm.
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.
Related: #1533 + #1837
OP's question was answered years ago. This issue has morphed a bit.
There are now:
- warnings at container start-up time if image related config files are outdated (#1533 / #2120)
- there is work to improve the documentation so that it is clearer which environment variables are install-time only versus can be changed anytime (with a container restart) via #2224
- it's important to use
occ config:list systemto check you real config (rather than looking at yourconfig.php) since the image takes advantage of Nextcloud's multi-config support
There are also some potentially other topical items that those in this issue may find of interest:
- Auto-configuration hooks:
- https://github.com/nextcloud/docker?tab=readme-ov-file#auto-configuration-via-hook-folders
- #2231
- #2226