I’ve created a new Golden Docker image for the Ghost Blogging blogging platform.

Attention. I do not maintaining these images actively anymore.

Why

Ghost documentation states that it’s better to use production configuration for live environments:

Essentially, production mode gives priority to performance, whereas development mode gives priority to information.

Since the official container for Ghost is fine for running in development mode, but it has some limitations for running in production. That, and the config file doesn’t have any easy way to tweak.

The main feature of the Golden Image is to enable production-ready use, with more configuration options[^1] build in backup and robust releases.

Usage of the image

For a quick test, do the following:

docker run --name some-ghost -p 80:2368 -d gold/ghost

It starts a new Ghost container and makes it available at http://localhost. For production, you need something more robust.

Production-ready example

Let’s create Host based volume ghost, that survives updates, and flexible in the configuration:

#Prepare host folder to keep Ghost data
sudo mkdir -p /var/lib/ghost
sudo chown 1000:1000 /var/lib/ghost
# Run container
docker run --name ghost1 --env-file /etc/default/ghost -p 80:2368 -v /var/lib/ghost:/var/lib/ghost -d gold/ghost npm start --production

This will run ghost in production mode by using host wired volume. Configuration is provided by /etc/default/ghost. Here an example of the configuration file.

# Ghost environment example
# Place in /etc/default/ghost

GHOST_URL=http://www.example.com
MAIL_FROM='"Webmaster" <webmaster@example.com>'
MAIL_HOST=mail.example.com
PROD_FORCE_ADMIN_SSL=true

Keep in mind you can switch between development and production modes whenever you like by using or not --production argument. My image uses same database file in both environments.

Docker-Compose example

I prefer to use docker-compose for such use case

ghost:
  image: gold/ghost:0.7.3
  command: npm start --production
  restart: always  
  ports: 
   - "2368:2368"
  volumes:
   - /var/containerdata/ghost/blog/:/var/lib/ghost
  environment:
   - GHOST_URL=http://example.com
   - PROD_FORCE_ADMIN_SSL=true
   - MAIL_FROM='"Webmaster" <webmaster@example.com>'
   - MAIL_HOST=mail.example.com
   - PROD_FORCE_ADMIN_SSL=false 

Here PROD_FORCE_ADMIN_SSL disables https for admin pages, assuming you use it via frontend load balancer like nginx.

Also, I prefer to use explicit versions gold/ghost:0.7.3 to prevent unintended updates.

Backups

Currently, backups can be done via:

docker run --rm --volumes-from some-ghost -v $(pwd)/backups:/backups gold/ghost /backup.sh

This will place the backup file in $(pwd)/backups directory of the host machine…

What next

For now, I’ve focused on volume on host pattern. In this scenario I have full access to data and configuration, as well restore of backups is not a problem, so this is not included in the image so far.

However, I plan to improve the image in sense of

  • Backup and restore functions for ==data-container scenario==
  • More config option if needed
  • Include more UI Themes, to give you more build in flexibility
  • Your ideas…