I have a docker instance of Nextcloud running on my server. Every time I update to a new version, it requires me to do database updates manually. Doing the updates is not the difficult part, the issue is that sometimes there are memory issues or since they are in a Docker container, the commands have to be changed.
Here is the list of some of the commands I have used to get my Nextcloud instance working:
Inside Docker container
First you must install sudo to be able to run the commands as the www-data user, since this user owns the files.
apt update && apt install sudo
Then you can enter sudo commands inside the docker container
The PHP_MEMORY_LIMIT is for when you have issues with php running out of memory, something i see all the time in NextCloud.
sudo -u www-data PHP_MEMORY_LIMIT=512 php ./occc db:add-missing-indices
sudo -u www-data PHP_MEMORY_LIMIT=512M php -f cron.php
sudo docker exec apache_app_1 su - www-data -s /bin/bash -c 'PHP_MEMORY_LIMIT=512M php /var/www/html/occ db:add-missing-indices' sudo docker exec apache_app_1 su - www-data -s /bin/bash -c 'PHP_MEMORY_LIMIT=512M php /var/www/html/cron.php' Other Usefull comands when dealing with Nextcloud and Docker:
Other usefull Nextcloud and Docker Commands
Run a script as a www-data user from docker host:
sudo docker exec nextcloud su - www-data -s /bin/bash -c 'php -d memory_limit=-1 -f /var/www/html/cron.php'