Cannot upgrade docker-based nextcloud

I have Nextcloud set up with docker-compose and after a failed upgrade nothing seems to work:

  • with version 20 the container doesn’t start: Can't start Nextcloud because the version of the data (23.0.1.2) is higher than the docker image version (20.0.14.2) and downgrading is not supported. Are you sure you have pulled the newest image version?
  • same with 21: Can't start Nextcloud because the version of the data (23.0.1.2) is higher than the docker image version (21.0.8.3) and downgrading is not supported. Are you sure you have pulled the newest image version?
  • and 22: Can't start Nextcloud because the version of the data (23.0.1.2) is higher than the docker image version (22.2.4.3) and downgrading is not supported. Are you sure you have pulled the newest image version?
  • 23 at least starts but upgrade refuses to run:
$ docker exec zo_nextcloud_1 php occ upgrade
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
Exception: Updates between multiple major versions and downgrades are unsupported.
Update failed
Maintenance mode is kept active
Resetting log level

See also:

$ docker exec zo_nextcloud_1 php occ status
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
  - installed: true
  - version: 23.0.1.2
  - versionstring: 23.0.1
  - edition:
  - maintenance: true
  - needsDbUpgrade: true
  - productname: Nextcloud
  - extendedSupport: false

Any options or did Nextcloud invent a time loop machine?

Which Docker image are you using?

nextcloud:XX-fpm-alpine

the problem is reported often. Downgrade is no supported, so the safe way to return to previous version after upgrade is full recovery of your data and database.

Sometimes removing/editing files like version.php helps

^ this is probably a sign of a fundamental issue that needs to be addressed?

I ended up solving by deleting version.php and trying each of the 5 last versions

may be… or may be users should RTFM:

Update to a newer version

It is only possible to upgrade one major version at a time. For example, if you want to upgrade from version 14 to 16, you will have to upgrade from version 14 to 15, then from 15 to 16.