Manually update Discourse and Docker image to latest

If you self-host Discourse, you occasionally need to run a manual update via the command line to get the latest security releases newest libraries. These updates are not picked up in admin/upgrade, which is why you’ll occasionally need to do this additional step.

  1. Discourse itself should be updated about twice a month, by clicking the “Update to Latest Version” button in your admin dashboard (admin/upgrade).

  2. Every two months we recommend SSH’ing into your web server (using putty or your favorite SSH client) and doing

    cd /var/discourse
    ./launcher rebuild app
    

    Especially if the upgrade page doesn’t show up or you have any issues when trying to upgrade.

  3. As for Ubuntu updates, make sure you have automatic security updates enabled for your Ubuntu! The command is:

    dpkg-reconfigure -plow unattended-upgrades
    

    However, that just covers critical security updates. Every so often you should get all the OS updates like so:

    apt-get update
    apt-get dist-upgrade
    

Due to the way docker packaging has changed you may also have to update your docker from lxc-docker or docker-engine packages. One way to do that is via the Docker script here (it will warn about an existing install but should upgrade ok):

wget -qO- https://get.docker.com/ | sh

This will now use the docker-ce main versions.

This is completely safe, we have never seen anything get broken by base Ubuntu updates.

To summarize:

  • update Discourse twice a month via web updater
  • update the container every two months
  • update the OS every six months

You could double these numbers and still be fairly safe, e.g. update Discourse once a month, container every 4 months, OS once every 12 months, and so on.

But you really, really want automatic security updates enabled in Ubuntu, as listed above.

FAQ

What is the right time to update?

It just depends on the time you have available and how close to bleeding edge you want to be. If you have non-official plugins, it is highly advisable to utilize a test/staging site. If you do not have any non-official plugins, you can likely upgrade immediately, but even then, some plugins may break for a couple of days as the team fixes them (there are a lot of them).

What is common practice when updating with many plugins installed?

If you have a lot of plugins, testing locally or on a test server is highly advised. Especially if you have non-official plugins, as something could have broken. If you find something does break, then it is a matter of, do you have time to fix it? Does the original plugin author have time to fix it? Either of those could take weeks. So at least this way, you simply have a broken test site and not a broken production site.

I’m running low on disk space

If you are running low on disk space (check with df) try clearing up old images using:

./launcher cleanup
apt-get autoclean
apt-get autoremove

Does updating the actual server version of Ubuntu matter since Discourse always operates in Docker?

It matters a lot less. But you should be on at least a currently supported LTS release of Ubuntu server. A 64-bit Linux OS with a modern kernel version is required.

164 Likes

The guides are reviewed and updated fairly frequently (this one looks like it had a little tweak in February). :+1:

The only one in there that I’m not personally familiar with is the docker one:

But I can vouch for the accuracy of the rest. :slight_smile:

2 Likes

I just ran through the entirety of these commands on my test site, including the docker update, and they worked without any problems.

4 Likes

5 posts were split to a new topic: How often should I update Discourse?

I’ve had a report of this causing an issue when run. I don’t think I’ve ever used it myself in the couple of years of having a DO test site.

Does anyone have any recent experience of it to say whether it’s still relevant advice or not?


I’ve just had a browse of the deleted posts and I found a couple where that part of the guide was raised before [1] and it seems @MarkDoerr ran it with no issues.

Though I’m still unsure if when/under what circumstances you’d be required to run it? Do I have too much faith in Docker Manager?


  1. I’ve undeleted them ↩︎

I’ve tried to run ./launcher cleanup, because after several rebuilds of the app I was running out of disk space, but get these errors:

"container prune" requires API version 1.25, but the Docker daemon API version is 1.24
"image prune" requires API version 1.25, but the Docker daemon API version is 1.24

So I just ran that update command in the hope that would fix it, but it didn’t the versions are still the same. Specifically under Server it says: API version: 1.44 (minimum version 1.24)

Then I ran the direct docker commands docker container prune and docker image prune. Now it gave back some 10 GB. :partying_face:

Is your os out of date? What does

cat /etc/issue

Give you?

And

docker --version

Ubuntu 22.04.3 LTS \n \l

Docker version 25.0.2, build 29cf629

1 Like

2 posts were split to a new topic: What’s the best/safest branch not break production site?