Upgrading the Blog Using Docker

This blog's engine is the fantastic Ghost. Through the time Ghost has been updated and is now at version 0.11.2 as of this writing.

Now upgrading this blog is one of the things I should be doing constantly to keep up with current features and patches. So I wanted to make that as simple as possible.

Using docker run

To separate the data from the application we are using Docker volumes.

docker run -v /var/lib/ghost -p 2368:2368 ghost:0.11.0

Now the container can be started and stopped as usual. This creates a data volume (implicitly) which can then be used later. Since this implicit creation is not very clear from the operator's perspective, we name the volume prior to using it using the docker volume command.

docker volume create --name ghostdata

We then use the named volume to run the app.

docker run -v ghostdata:/var/lib/ghost -p 2368:2368 ghost:0.11.0

Now we're finished.

Upgrading is easy, just restart a container using a new version:

docker run -v ghostdata:/var/lib/ghost -p 2368:2368 ghost:0.11.2

Using docker-compose

Ghost can be run using a data volume and the Ghost image from Docker Hub.

The compose file for this:

version: '2'

services:
  blog:
    ports:
      - 2368:2368
    image: ghost:0.11.0
    volumes:
      - /var/lib/ghost

That's it, you are done. The entire data volume handling is taken off of your shoulders.

To upgrade the application, simply replace

image: ghost:0.11.0

with

image: ghost:0.11.2

Then restart the app.

docker-compose stop
docker-compose up -d

Comparison

Both approaches are easy. Currently, I am using the docker-compose variant which is a little bit more declarative by using the compose file.

Regardless of the approach, knowing how to use data volumes properly is a must. And in the end, it is probably only a matter of whether you would like your setup stored in a docker-compose.yml or inside a few Shell scripts.