Issues with docker upgrade

Initially I had Nextcloud (version 15) running happily as a docker container, but upgrade has been a headache. In my docker-compose file I had set

image: nextcloud:15-apache 

and mindful of upgrading one version at a time, I tried changing that to nextcloud:16-apache, but the resulting container refused to start. I tried a few other things, and discovered that the database version was, and the nextcloud version was something else. So I threw caution to the winds and tried


which has given me a container that starts, but which I can’t access with a browser. Attempting to log in produces

Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.

I have tried to enter the docker container and see what I can do with occ. The status is:

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:
  - versionstring: 20.0.1
  - edition: 

However, for example the command php occ upgrade produces:

Exception: Updates between multiple major versions and downgrades are unsupported.
Update failed

I’m not quite sure how to recover from this. Given that all my data is stored external to the container, I could possibly completely remove it and build a new container from scratch (using image: nextcloud:latest).

But can I somehow fix the current container? Many thanks!

This happened while updating from 15 to 16? You sure it didn’t happen when you tried to jump up to 20x?

You are correct on being able to simply remove your container and pull the new one. That is the Docker way. I recommend consulting Docker documentation if it helps with tweaking your compose file. Obviously, always keep backups.

Do you have your /data living as a separate volume?
Example setup: /data lives on a volume located somewhere such as /home/nextcloud.
Nextcloud container, separate but linked to the volume, can be stopped and removed if necessary.
Pull latest image, and throw the latest container back up.
Compose will link it to your old volume.

I’ve done this with success.