blog logo Running Ghost on Docker

I've been moving most of my services to Zeit. This blog is hosted with them and runs as a Docker container. Going from a traditional server to a container wasn't as easy as I thought. The progress is simple but the guidance wasn't fully there.

My goal with this post is to make the process of getting Ghost running on Docker as easy as 🎂!


The documentation I found helps you get ghost up and running in a testing environment. Once you get into production environment, your requirements will change. In testing, you use a local SQLite or mySQL database. In production, you should have an immutable container, which means it can not change. Writing a post will violate that. Every post you write will overwritten when your container restarts.


You need an external database. That was pretty obvious but which service should you use and how do you configure it?

I recommend Heroku's ClearDB add-on. They have a free tier and fair pricing.

Your configuration file should look like the code below. We will focus only on our production settings.

Config.js file for Ghost. Put the content of this into a file named config_w_heroku.js.

config = {  
  production: {
    url: '',
    mail: {
      transport: 'SMTP',
      options: {
        host: '',
        port: 465,
        service: 'SES',
        auth: {
          user: '*********',
          pass: '*********************************'
    database: {
      client: 'mysql',
      connection: {
        host: '',
        user: '******',
        password: '**********',
        database: '*****************',
        charset: 'utf8'
      debug: false
    server: {
      host: '',
      port: '2368'
    fileStorage: false,
    paths: {
      contentPath: path.join(process.env.GHOST_CONTENT, '/')

DockerFile to build your blog. This will pull the official ghost image. Then it will customize the container based on your configuration. I've included the lines required to copy a custom theme into your container. They are commented out in below.

# Grab latest official ghost container
FROM ghost:latest

# Useful labels
MAINTAINER Gil Ferreira <>  
LABEL name=""

# Setup environment variables
ENV GHOST_SOURCE /usr/src/ghost/  
ENV NODE_ENV production

# Remove config.js
WORKDIR /usr/src/ghost/  
RUN rm config.js

# add our own configure file
ADD config_w_heroku.js config.js

# Copy in our custom theme
# COPY gleak/ $GHOST_SOURCE/content/themes/gleak/

# QA - show file. Can be removed
# RUN ls -la $GHOST_SOURCE/content/themes/

If you are using Zeit, you can type in now from your working directory.

Your server is now deploy!!

🐋 +👻 = 🎂