MyBB Community Forums

Full Version: How to upgrade via docker-compose?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have created a basic installation of MyBB for educational purposes. The goal is to learn more about Docker and MyBB is a good fit as it requires several services to run.

I am using the docker-compose.yml shown at the bottom of MyBB's Docker project page: https://hub.docker.com/r/mybb/mybb/

My forum was installed on version 1.8.22. and I am trying to understand how to upgrade to 1.8.23 via docker-compose. I have run:
docker-compose pull
docker-compose up -d

These commands pulled the latest version of MyBB, Nginx, and PostgreSQL. The up command then restarted the containers with the latest images.

When navigating to the admin panel I still see the warning about upgrading from 1.8.22. How can I trigger the upgrade successfully when using docker-compose to manage the containers?
I would still like to know the official way of upgrading via docker-compose as I am not satisfied that my way is appropriate for containerized environments.

Here is how I used Docker to upgrade from 1.8.22 to 1.8.23. In the top level of my project I ran:

# creates the new temp dir
mkdir mybb_1.823

# run an ephemeral container to init the new directory
docker run -it --rm -v ${PWD}/mybb_1.8.23:/var/www/html mybb/mybb:1.8.23

# copy over the changes with rsync archive mode 
rsync -a mybb_1.8.23/ mybb_1.8

# remove the temp dir
rm -rf mybb_1.8.23

# remove the lock file under the main install to allow upgrade
rm -f mybb_1.8/install/lock

# go to install page UI and upgrade

While I could do that each time I would like a more seamless way to automate the upgrades into a one-liner. I have snapshots of each container so if anything goes horribly wrong I can roll back to a point in time.

What thoughts does the community have on my hackish way of upgrading via docker-compose?
Welcome to MyBB Community.

at present we do not have official method as such for upgrading MyBB
version through Docker. I'll request an expert of Docker to respond.
I posted on the MyBB discord this morning a link to this thread. I'll just quote what was said over there

Kawaii Wrote:The Docker container isn't really for public consumption, I'm really the only one using it to test PRs and plugins etc.

It's not designed to be upgraded at all, there are no mechanisms within the container to facilitate upgrades.
This needs some work, at the moment I'm using the container purely to test plugins and PRs, not actively using it to run a production forum. Your method is probably fine, but as you stated - is not the most seamless. I did upgrade a container forum once by simply extracting the changed_files_18*.zip archive into the mount point and running the upgrade the usual way.
(2020-07-27, 11:11 PM)Qyuinn Wrote: [ -> ]I would still like to know the official way of upgrading via docker-compose as I am not satisfied that my way is appropriate for containerized environments.

Here is how I used Docker to upgrade from 1.8.22 to 1.8.23. In the top level of my project I ran:

# creates the new temp dir
mkdir mybb_1.823

# run an ephemeral container to init the new directory
docker run -it --rm -v ${PWD}/mybb_1.8.23:/var/www/html mybb/mybb:1.8.23

# copy over the changes with rsync archive mode 
rsync -a mybb_1.8.23/ mybb_1.8

# remove the temp dir
rm -rf mybb_1.8.23

# remove the lock file under the main install to allow upgrade
rm -f mybb_1.8/install/lock

# go to install page UI and upgrade

While I could do that each time I would like a more seamless way to automate the upgrades into a one-liner. I have snapshots of each container so if anything goes horribly wrong I can roll back to a point in time.

What thoughts does the community have on my hackish way of upgrading via docker-compose?

If it was me, I would do it a bit different.

In your compose file you would have this:
services:
  mybb:
    image: mybb/mybb:latest

Change it to:
services:
  mybb:
    image: mybb/mybb:1.8.23

Then when it is time to upgrade, backup whatever you have to, then update the compose file to:
services:
  mybb:
    image: mybb/mybb:1.8.24
Then run: docker-compose up -d --remove-orphans

This will cause docker-compose to pull the latest image and recreate the mybb container. 
I haven't played with this myself yet, so I am not sure what exactly gets deleted etc and what needs fixing, but this is generally one way of doing it in docker-compose.


The next step, is to automate a build for your own site, where you import the mybb container then run the commands for customizations you want for your own board. This is then the image you would want to deploy for yourself. Docker hub even allows you to automate this build process where by it will rebuild the image when mybb releases a new image.

The one big problem we do have with mybb though, is that an admin has to go to the /install/ folder and do the rest of the upgrade process. It would be great if this could also be automated one way or another, but maybe in the future if we lucky.

Anyways, give the above a shot and see how it works out for you.