Updating ghost

Updating ghost
Photo by Allen Ng / Unsplash

A reminder that Docker isn't just "set it and forget it"

In a previous post, I discussed setting up this blog, around a year and a half ago. In that time, much has changed in my life and much has changed on the Ghost github repository.

GitHub - TryGhost/Ghost: Turn your audience into a business. Publishing, memberships, subscriptions and newsletters.
Turn your audience into a business. Publishing, memberships, subscriptions and newsletters. - GitHub - TryGhost/Ghost: Turn your audience into a business. Publishing, memberships, subscriptions and...

These past few days, I've got loads more time than before and I suddenly got the urge to post on my blog again, when I was greeted with a message to the tune of "You are running an outdated version of Ghost, which is very vulnerable. Update immediately!". At first I ignored the message and went on writing a post, but it kept nagging me. In the end, I conceded and went to fix the issue - it's just a docker container, I thought to myself, it should be simple.

It wasn't that simple.

The first issue I ran into was that I couldn't find the docker-compose file anywhere on my server. Then I realized I hadn't yet used docker-compose at that time, and realized I stored all my docker run commands in text files on my laptop... :/

Fortunately, it was easy enough to find on my laptop, and I decided to place it directly on the server next to ghost's files, named docker-config.sh. Now whenever I need to change anything in the config, it's as easy as stopping, deleting the container and running bash docker-config.sh. (now that I think about it, the first two tasks could be automated as well...)

So, everything solved, let's just run docker pull ghost:latest and start the container, and it should just work, right? I reloaded the webpage in anticipation, but nothing happened... I checked the container's status with docker ps -a and saw it was returning a "Restart (2)" error. After a tiny amount of googling I found this very neat command that allows me to see what's going on in the container's logs. sudo docker logs --tail 50 --follow --timestamps ghost

Docker: Container keeps on restarting again on again
I today deployed an instance of MediaWiki using the appcontainers/mediawiki docker image, and I now have a new problem for which I cannot find any clue.After trying to attach to the mediawiki front
(Thanks Matt!)

I quickly discovered the issue: ghost had gone through multiple major versions in the time I was busy, and it couldn't migrate to the latest version. I somehow "forgot" Docker is just an abstraction layer, and underneath it is still a living, breathing, in development app, that has its own quirks and peculiarities.

The solution: cautiously update from one version to the next. To find the versions I was going to need, I used a feature of docker hub I just discovered, looking up all the possible tags in the tags tab. I first began with the last 3.x.x version, it being 3.42.9. After it successfully spun up, I shut it down and moved to the next version by date (4.3.3), then the last 4.0 version (4.48.2) and then to the latest version (5.2.3). I used the above log tracing command each time to check that it updated properly.

I also learned that using the latest tag isn't the best idea and that it's probably safer to always specify a version. ;)