What's the right way to upgrade Nextcloud on Docker?

I haven’t been able to find a definitive guide to upgrading Nextcloud on Docker. I was hoping you could just update the Docker container and it would handle the rest, but I just tried that and it didn’t work.

What is the right way to upgrade to a new version of Nextcloud on Docker?

Nextcloud version : Upgrading from 23.0.4 to 23.0.5
Operating system and version : Docker version 20.10.16 on Ubuntu 20.04
Container tag: nextcloud:23-apache

The issue you are facing: Web UI stays in “Maintenance mode” forever.

Is this the first time you’ve seen this error? (Y/N): Yes (first time I’ve tried to upgrade minor versions since installing on Docker)

Steps to replicate it:

  1. Rebuild Docker container
  2. Start new container
  3. Open Nextcloud in browser
  4. Observe Maintenance Mode screen

The output of your Nextcloud log in Admin > Logging: Can’t get there

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

<?php
$CONFIG = array (
  'overwrite.cli.url' => 'https://<my URL>',
  'htaccess.RewriteBase' => '/',
  'trusted_domains' =>
  array (
    0 => '127.0.0.1',
    1 => 'localhost',
    2 => '<internal IP>',
    3 => '<external IP>',
    4 => '<my domain>',
  ),
  <various mail_ settings>
  'overwriteprotocol' => 'https',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => 'redisr',
    'port' => 6379,
    'password' => '...',
  ),
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'passwordsalt' => '...',
  'secret' => '...',
  'datadirectory' => '/ncdata',
  'dbtype' => 'mysql',
  'version' => '23.0.5.1',
  'dbname' => 'nextcloud',
  'dbhost' => 'mariadbn',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => '...',
  'installed' => true,
  'instanceid' => '...',
  'loglevel' => 0,
  'maintenance' => false,
  'default_phone_region' => 'US',
);

The output of your Apache/nginx/system log in /var/log/____:
Docker logs say:

Configuring Redis as session handler
Initializing nextcloud 23.0.5.1 ...
Upgrading nextcloud from 23.0.4.1 ...
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
Setting log level to debug
Turned on maintenance mode
Updating database schema
Updated database
Disabled incompatible app: breezedark
Disabled incompatible app: bruteforcesettings
Disabled incompatible app: calendar
Disabled incompatible app: contacts
Disabled incompatible app: deck
Disabled incompatible app: documentserver_community
Disabled incompatible app: event_update_notification
Disabled incompatible app: files_antivirus
Disabled incompatible app: mail
Disabled incompatible app: maps
Disabled incompatible app: onlyoffice
Disabled incompatible app: quota_warning
Disabled incompatible app: spreed
Disabled incompatible app: tasks
Disabled incompatible app: twofactor_nextcloud_notification
PHP Fatal error:  Allowed memory size of 536870912 bytes exhausted (tried to allocate 467814792 bytes) in /var/www/html/lib/private/Installer.php on line 300
Configuring Redis as session handler
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.20.17.4. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.20.17.4. Set the 'ServerName' directive globally to suppress this message
[Sat May 21 12:14:01.668742 2022] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.53 (Debian) PHP/8.0.19 configured -- resuming normal operations
[Sat May 21 12:14:01.668826 2022] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
172.20.15.5 - - [21/May/2022:12:14:07 -0500] "GET /svg/core/actions/clippy?color=fff&v=2 HTTP/1.0" 503 11962 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36"
(there's more, but doesn't look relevant)
2 Likes

Sounds like a bug.

Updating a Docker-based Nextcloud is documented at GitHub - nextcloud/docker: â›´ Docker image of Nextcloud , and it does sound like you are doing it right (pull / rebuild a new image, destroy old container, start new container).

2 Likes

Could this line in the log file be the key to the problem?

That seems like a lot of memory to allocate … do I have too many apps loaded or something?

I had the same problem with upgrading from 23.0.3 to 23.0.4. Were you able to resolve it?

Not exactly; more like the problem just went away. I restored everything from backup, retried the upgrade, and it all worked fine. I really have no idea what was different the second time. Frustrating.

1 Like

Just tried to upgrade from 24.0.3.2 to 24.0.4.1; same problem. This happens nearly every time I upgrade.

I see tons of posts regarding “PHP Fatal error: Allowed memory size of xxx bytes exhausted”, but the solutions either don’t work or don’t apply to the Docker image.

Surely there’s a solution to this?

Dang, again? Any luck with this recently? I’m wondering if you went to v25, and if that’s any better.

I’ve currently got the exact same issue with upgrading from 26.0.2.1 to 27.0.0.8.

`docker logs nextcloud`
docker logs nextcloud
Initializing nextcloud 27.0.0.8 ...
Upgrading nextcloud from 26.0.2.1 ...
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
Setting log level to debug
Turned on maintenance mode
Updating database schema
Updated database
.....

What about:

You may use your browser or the occ upgrade command to do the upgrade

Shouldn’t be needed with docker, right?

But in contrast to OP my config.php after the update still shows the old version 26.0.2.1.

EDIT:

I restored my VM from backup too, and now the upgrade worked. I tried to reproduce the initial issue, with no success :confused:

I’m having the exact same issue I believe.

My NC container (image: Nextcloud on Docker hub) is auto updated by Watchtower but since the “Update Nextcloud now” screen shows up before the new image is pushed to the hub, it stays like this.

Watchtower logs show that NC is being Updated but the screen stays in “update now”. If I click on update, it works as expected and works again after that but it keeps everyone from logging in and all apps stop to sync (as well do my cron jobs) until I hit that “update” button.

There should be either a check “has NC been updated” on restart or “disable nextcloud version updates” for the docker version since it is done from the docker side.

Have a good one! :slight_smile:

@Haui and @Alklaud - While the underlying cause of the original poster’s upgrade issue is unknown, the reason the upgrade process failed in Docker is because something is causing their PHP process to allocate a ton of memory during the upgrade run.

Are you both also seeing the PHP Fatal error: Allowed memory size of... message or are you simply saying you’ve having trouble getting the upgrade to complete too?

I ask because while you all may not be able to update, the causes may be entirely different. Please post your full docker compose logs <container_name> (or equivalent).

Also, for context it would also be helpful to see your Docker Compose files (or run commands, if you’re not using Compose for some reason).