Upgrade one major at a time with Docker

Hi,
I have a perfectly working Nextcloud instance installed via docker-compose.
The docker-compose.yml file is the following:

version: '3'

services:
  db:
    image: mariadb
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: always
    volumes:
      - /my/db/location:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=my_password
    env_file:
      - db.env

  app:
    image: nextcloud:apache
    restart: always
    volumes:
      - /my/nextcloud/location:/var/www/html
    environment:
      - MYSQL_HOST=db
      - VIRTUAL_HOST=my_virtual_host
      - LETSENCRYPT_HOST=my_host
      - LETSENCRYPT_EMAIL=my_email
    env_file:
      - db.env
    depends_on:
      - db
    networks:
      - proxy-tier
      - default

volumes:
  db:
  nextcloud:

networks:
  proxy-tier:
    external: true

From the overview section in the Admin account, the current version appears to be 16.0.3.
The overview section also prompts me to update to version 16.0.8.

However, I would like to upgrade to Nextcloud 18, but the documentation explicitly says that upgrades between two or more major versions are not supported.

Given that Iā€™m really ignorant about docker, the problem is that I cannot find anywhere how should I upgrade to version 17 first, and then to 18.
First of all, the docker-compose.yml doesnā€™t seem to contain any information about the current version, and I cannot find any information about specifying a particular version for docker-compose to pull in general.

I suppose that should exist a way to specify a precise version in the ā€œimage:ā€ line, but I canā€™t figure out how.

What I have to do in order to upgrade to Nextcloud 17 avoiding the last version until I have completed the first upgrade?

Thanks.

Hi,

I would login to the nextcloud instance as admin (ncp) and go to settings > overview and from there upgrade to NC 17 and then NC 18.

Thanks for you answer. From the overview settings I only see the option to upgrade to version 16.0.8. Should I switch to Beta channel to see new versions? In any case, trying with 16.0.8 it start a download from the browser for an archive with the new release. I thought that the upgrade could have been made through docker-compose directly. Isnā€™t it possible?

EDIT:
I have switched to Beta and now Nextcloud 17 is the latest release. Probably the 18 update has not been rolled out for me yet. However, clicking ā€œOpen Updaterā€ brings me to the files section, but no updater is shown. How should I do this? Can i download the zip instead and put it in the files folder of the docker installation? Would that work or is intended only for manual installations without docker?

Anyway, I would be glad if this could be controlled by pulling a specific version with docker.

I wouldnā€™t switch to beta. You have to update to the latest on NC 16 in order to see the next major update. So you update to 16.0.8 first and then you will see 17 and then 18. Iā€™m running Nextcloudpi docker container and thatā€™s how I updatedā€¦

Edit:
And as far as I know, if you switch to beta you canā€™t switch back to stable anymoreā€¦

Ok, thanks, thatā€™s useful information. Iā€™m in fact trying to install version 16.0.8. The question is: how should I do that? Iā€™ve tried replacing the files in the folder mapped to /var/www/html with the ones in the .zip downloaded from the overview section, but it doesnā€™t work, the browser says ā€œBad gatewayā€ (Iā€™ve installed nextcloud behind an nginx reverse proxy).

Now i put back the original files and the previous version started working again.

Normally you shouldnā€™t have to do anything other then clicking to ā€˜Open updaterā€™ which should launch updater and download and update everything and reboot automaticallyā€¦

That is what I imagined too. Unfortunately it brings me to the files section and nothing happens. By the way, are you sure this method works for docker installations too? in the docker page of nextcloud only talks about pulling new docker versions by the command line.

This is where my knowledge ends I guess. Iā€™m running a NextcloudPi docker container. This is what I followed:

https://docs.nextcloudpi.com/en/how-to-get-started-with-ncp-docker/

I like the extra options of NCP and the backup solution works very well which is very important to meā€¦

nope. not with docker.

edit your docker compose and use a ā€œversion tagā€. e.g. nextcloud:17-apache for your image.
stop, start. edit ā†’ nextcloud:18-apache. stop. start.

well. try docker inspect <image-name> to get the needed info to recreate/update your docker compose file.

Also with NextcloudPi docker image?

There is not much info on the official link I followed: https://docs.nextcloudpi.com/en/how-to-get-started-with-ncp-docker/

It executes ncp-update command in the container but no info on instance update so I assume instance update has to be done from within the nextcloudpi app (localhost:4443) which is same as updating with admin from the instanceā€¦

you are right. that one is different.

but thatā€™s the ā€œnormalā€ nextcloud image. or?

That is exactly what I meant! Is that just an example or is actually working with nextcloud?
Also, is there a way to search with docker to get a list of the possible versions existent for a specified container?

Yes, itā€™s the default image, but it doesnā€™t specify wich version of nextcloud (16,17,18) it should pull. I suppose itā€™s normal, but my lack of knowledge leaves me wondering how say to the docker-compose ā€œPull version 17 instead of the lastā€ when executing

sudo docker-compose pull

I hope my doubt is clear.

EDIT:

I used

image: nextcloud:17-apache

in the docker-compose.yml file, like @Reiner_Nippes suggested, and it worked like a charm! It pulled nextcloud 17 and it opened already updated without any updater prompt (not like with manual installations updates).

Thank you very much!!! I will mark your answer as the correct solution!

youā€™ll find the update mechanism in the entrypoint.sh

which version is packed in the image youā€™ll find in the dockerfile.

to find all available tags you can use the docker website

https://hub.docker.com/_/nextcloud?tab=tags

or use the docker api

https://registry.hub.docker.com/v1/repositories/nextcloud/tags

Thank you very much! You helped me a lot!

I saw the various tags on Docker Hub. However the tags are not something that is necessarily adopted by the various dockers, am I right? Looking for example at the GitLab dockers, there is no tags section.

Is it something that Nextcloud decided to use for its docker but not taken for granted with every docker?

first of all there is a docker command to tag an image

and to push it to a docker registry

you can address images by this tags. thatā€™s ā€œnormalā€ docker behavior.

if people are tagging their images depends on the people.

build your own private images you might not care because you always want to use latest. providing official image like nextcloud is doing itā€™s very nice to tag your images. all major vendor do tagging right. otherwise you would know whichversion you are using and how to upgrade.

btw: upgrade. please note that tags are not always pointing to the same image. e.g.: nextcloud:apache is always the latest version with apache. nextcloud:18-apache will always be the latest major version 18. and nextcloud:18.0-apache will pin your image to the lastest 18.0.

thatā€™s quite usefull if you use ā€œauto updateā€. have look at

https://hub.docker.com/r/pyouroboros/ouroboros
or
https://hub.docker.com/r/v2tec/watchtower

Many thanks for your detailed answers, you cleared all my doubts!