Ghost : how to upgrade your docker image

Ghost : how to upgrade your docker image

If like me you need to upgrade ghost to the latest version while running it in docker, here are the different steps.

  1. Backup

First things first, save your content. Ghost made it super easy: sign-in with your account, open settings and go int Labs. Click on Export and you'll get all of your content serialized in a json file.

2.  Stop your running image

Inspect the image if you don't remember how it was configured. You could have port bindings, environment variables or shared volumes. Here is my configuration:

Port host Port image
8095 2368
Environment var Value
VIRUTUAL_HOST blog.cemsoyding.com
url http://blog.cemsoyding.com
NODE_ENV production
Mounted volume (host) Path in image
/share/ghost blog.cemsoyding.com

3.   Pull latest ghost image from docker hub

In my case, I've simply used the image explorer in the UI of my NAS for this step.

4.    Create your new container

Reconfigure it with the settings that you grabbed from your previous container.
If you were using SQLite to store your posts, just now that from v5.x onward, the de facto storage option for Ghost is MySQL. You can chose to to install a MySQL server (or run it in another docker image) or you can opt for the following additional environment settings to force ghost into using SQLite.

Environment var Value
database__client sqlite3
database__connection__filename "content/data/ghost.db"
database__useNullAsDefault true
database__debug false

5.    Import you saved content

Run your container and make sure that it is up and running by browsing your url. You should either see your content displayed (yeaah you're done) or just an empty shell. Don't panic, just create your account again and go into settings->Labs and import your json file. When the import is done, your blog should be back online ;).