ReinerNippes / nextcloud_on_docker

Run Nextcloud in Docker Container on various Linux Hosts
MIT License
203 stars 48 forks source link

How to upgrade Nextcloud container #40

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hi @ReinerNippes

What is the best approach to updating my Nextcloud container in this setup?

Thanks.

ReinerNippes commented 4 years ago

Just wait. There is a container called watchtower. It will update all images.

If you don't want that. Or fine tune it a bit.

In group_vars/all.yml you can define which image version will be used. e.g. with docker_postgres_image: 10-alpine watchtower will update postgres release 10 based on alpine. actual this is 10.11-alpine. if there will be a version 10.12-alpine you'll get the update. updates of the underlying alpine images are also included.

here https://github.com/ReinerNippes/nextcloud_on_docker/blob/082b75624674c06a8caa8bad5b46d04ead2a231f/roles/docker_container/tasks/watchtower.yml#L8 you find the schedule for watchtower.

find these container labels

https://github.com/ReinerNippes/nextcloud_on_docker/blob/082b75624674c06a8caa8bad5b46d04ead2a231f/roles/docker_container/tasks/database.yml#L66

to turn on and off the auto update of each container.

don't update traefik to version 2. the config is incompatible with version 1.7.

if you want to upgrade a container image like postgres or redis. make a backup. change the image version in group_vars/all.yml and just run this role

https://github.com/ReinerNippes/nextcloud_on_docker/blob/082b75624674c06a8caa8bad5b46d04ead2a231f/nextdocker.yml#L11

copy nextdocker.yml and delete all other roles.

it should be safe to just run nextcdocker.yml without modification because the playbook should be idempotent. but this not tested very well.

ghost commented 4 years ago

Perfect. I wasn't sure if the nextcloud container had the watchtower label but using docker inspect I can see it's got it. 😄 Thanks for the thorough answer.

tzmemo commented 4 years ago

If I may chime in here, I also saw the update from 18.0.0 to 18.0.1 today, but I cant find a label on nextcloud:fpm-alpine:

$ grep com.centurylinklabs.watchtower.enable roles/docker_container/tasks/*
roles/docker_container/tasks/adminer.yml:      com.centurylinklabs.watchtower.enable:         "true"
roles/docker_container/tasks/collabora.yml:        com.centurylinklabs.watchtower.enable:            "true"
roles/docker_container/tasks/database.yml:          com.centurylinklabs.watchtower.enable:         "true"
roles/docker_container/tasks/database.yml:          com.centurylinklabs.watchtower.enable:         "true"
roles/docker_container/tasks/nginx.yml:      com.centurylinklabs.watchtower.enable:            "true"
roles/docker_container/tasks/onlyoffice.yml:        com.centurylinklabs.watchtower.enable:            "true"
roles/docker_container/tasks/portainer.yml:      com.centurylinklabs.watchtower.enable: "true"
roles/docker_container/tasks/redis.yml:      com.centurylinklabs.watchtower.enable:         "true"
roles/docker_container/tasks/traefik.yml:      com.centurylinklabs.watchtower.enable:         "true"
roles/docker_container/tasks/traefik.yml:      com.centurylinklabs.watchtower.enable: "true"

$ docker inspect nextcloud:fpm-alpine |grep -i labels -A2
            "Labels": {},
            "StopSignal": "SIGQUIT"
        },
--
            "Labels": null,
            "StopSignal": "SIGQUIT"
        },

So I tried to add the watchtower.enable line next to the nextcloud_traefik_label, but then Ansible bailed out with syntax errors.

Finally I removed the image and ran nextcloud.yml, so it pulled the new image, but why isn't it using watchtower?

ReinerNippes commented 4 years ago

Sorry. The nextcloud container is different. Because there are two possible images. fpm-php and apache. The later has traefik labels. If you run fpm-php these labels apply to the nginx container.

Therefore the nextcloud container labels are here in variable

https://github.com/ReinerNippes/nextcloud_on_docker/blob/082b75624674c06a8caa8bad5b46d04ead2a231f/roles/docker_container/vars/main.yml#L4

The switch which labels are used is coded here.

https://github.com/ReinerNippes/nextcloud_on_docker/blob/082b75624674c06a8caa8bad5b46d04ead2a231f/roles/docker_container/tasks/nextcloud.yml#L46