5$ Cloud Part 2: Upgrading Nextcloud Docker
The reason I looked past the steeper learning curve and opted to use Docker to host my Nextcloud instance is the separation of the software from my data.
This makes updating easy. I can completely wipe out my containers, pull down the updated ones, start them back up, and resume where I left off.
This article serves to cover the Nextcloud update process and works through solving a common issue that Nextcloud may have when being updated.
Updating
The Nextcloud Docker readme details the update process for the container. This process can also be used for docker compositions.
$ docker-compose pull
$ docker-compose down
$ docker-compose run -d
Once everything is started up you should be able to browse back to your Nextcloud instance on the web and see the upgrade screen.
Some update issues
As I was spinning my docker composition back up, I noticed that I had forgotten the -d
flag. I instinctively hit ctrl c
so that I could have my shell back.
This was a mistake. I had cancelled in the middle of Nextcloud's update routine.
When I brought the docker composition up this time Nextcloud was stuck in maintenance mode. It was now necessary for me to log into the containers directly and manually intervene.
I first had to find the correct container, 03293d
, which is the one using the nextcloud:fpm
container.
A few minutes on Google and you will find the suggestion of using occ
to turn off maintenance mode manually. Running $ docker exec -it 03293d bash
gets me to a shell as root
so that I can execute the command.
Doing so will give you an error message which asks you to prefix the command with su - www-data
.
Service Accounts
It turns out that there is an alternative shell located at /bin/nologin
. This is commonly used for service accounts so that a shell cannot easily be opened from exposed users. We can verify this by looking at the www-data
's passwd
entry.
$ grep www-data /etc/passwd
www-data;x;33:33;www-data:/var/www:/usr/sbin/nologin
I have to somehow execute bash
under www-data
's UID.
Stumped, I popped over to the docker doc (heh) for docker exec
so that I can interpret how to connect to the container.
$ docker exec -it -u www-data 03293d bash
Will log me into a new bash
shell as www-data
. Once in, I browsed back to /var/www/html/
and disabled maintenance mode.
The author of this container was very nice to set $HOME as /var/www so that it is obvious from which directory the web server is serving from.
$ ./occ maintenance:mode --off
It should have executed the command without issue.
Finally, browse back to your Nextcloud instance in your internet browser. You should see an option to begin the Nextcloud upgrade.
Success!
These troubleshooting steps should prove useful in the imminent Nextcloud 13 release :smile:
Update: Nextcloud 13 Release
I had opted to wait to pull down Nextcloud 13 because of two open issues. The most important was that the the build service was failing for the Nextcloud 13 image. This failure was resolved in Pull Request #244. As users pulled down the next Docker images they found freetype was not enabled on the webserver portion. This was fixed earlier today and is included in PR #250.
This results in a seamless update by performing the following 3 steps:
$ docker-compose down
$ docker-compose pull
$ docker-compose up -d
Soon the webserver will finish initializing and, when you browse to your site, you will end up right back at the home screen.
Note: I noticed that if running docker-compose rm
docker will state there are no containers. This is because docker-compose down
automatically removes the containers. As a result I have removed the docker-compose rm
command from the procedure.
These troubleshooting steps should prove useful in the imminent Nextcloud 13 release :smile:.