Nextcloud AIO - How to persist changes to php.ini in the nextcloud_aio_nextcloud container that resets after an update

I’m running the Nextcloud AIO docker container. This consists of a master container that then runs the other containers such as the apache, and sql server containers. With this working I want to change it so that after 4 hours of inactivity the user is automatically logged out of the web browser Nextcloud page.

I have found the options I need to change to do this, which can be found here.

However an important point to note with the session_lifetime option is this:

The maximum possible time is limited by the session.gc_maxlifetime php.ini setting which would overwrite this option if it is less than the value in the config.php

By default the session.gc_maxlifetime is 1440 seconds which is 24 minutes. I can confirm my session expires after 24 minutes even if set session_lifetime to 4 hours.

I have managed to change the session.gc_maxlifetime by going into the nextcloud-aio-nextcloud container navigating to /usr/local/etc/php/ making a copy of the php.ini-production or php.ini-development and creating a new php.ini file. I then delete the php.ini-development and php.ini-production which leaves me with my newly created php.ini file with which I can change the session.gc_maxlifetime. With this I can confirm that my desired goal of a timeout after 4 hours of inactivity is achieved. This is the only way I have found to be able to achieve this. And I have created a bash script to do all of this.

However, every time the containers restart for updates, the changes I made to the php.ini are reset. The php.ini is gone and has been replaced with the php.ini-development and php.ini-production again. I have tried to find the corresponding Dockerfile in both the nextcloud container and the master container but I can’t find one. I think you can set things in the Dockerfile to make changes to a container at boot? I only have a basic understanding of Docker.

I’ve done a lot of research into this but haven’t found anything helpful. The only thing mentioned in regards to session.gc_maxlifetime is this. Where the answer refers to sessions being managed by redis. Now there is a running redis container in the nextcloud AIO suite but I have found nothing about session max lifetimes in that container. The answer in that post also points to another issue but that has nothing to do with my problem.

So I’m really not sure how to address this. Ideally I’d want to be able to persist the settings I make to the php.ini which includes the creation and deletion of the various php.ini files as well as the change to session.gc_maxlifetime in php.ini. And those settings are kept after the container reboots. All of the other containers are managed, updated and rebooted by the master container which provides a web interface to do so.

I am welcome to other ways of overriding the session.gc_maxlifetime.