Ghost blog on Docker Cloud

Docker Hub

Ghost has a nice documentation of their official image on Docker Hub

Configuration volume mount

I strongly recommend that even when testing locally you mount a config directory into the container. The following code will mount a ./ghost-blog directory relative to where you run the command.

docker run -v $PWD/ghost-blog:/var/lib/ghost ghost  

Without any additional configuration, Ghost will put an sqlite database file and its configuration into the mounted directory.

Let Ghost send mail with Mailgun

The easiest way to let your Ghost blog send mail is to sign up for Mailgun. You get 10000 free mails per month.

Other Ghost mail alternatives: Ghost mail configuration.

When you have your SMTP account credentials from mailgun, use them as user/pass for Mailgun service in config.js below, and use the configured Mailgun domain in the from address too.

Ghost's config.js

The configuration file is divided into multiple environments: production, development, testing. By default it runs development, but we will configure and run production by editing the configuration and then passing environment variable NODE_ENV=production to our container.

Do not mind the rest of the config, but fill in the production part like following. Replace "example.com" with your domains. The mail domain doesn't have to be the same as the site URL.

config = {  
    production: {
        url: 'https://example.com',
        mail: {
            from: '"Ghost Mailer" <[email protected]>',
            transport: 'SMTP',
            options: {
                service: 'Mailgun',
                auth: {
                    user: '[email protected]',
                    pass: 'secretpassword'
                }
            }
        },
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(process.env.GHOST_CONTENT, '/data/ghost.db')
            },
            debug: false
        },

        server: {
            host: '0.0.0.0',
            port: '2368'
        },
        // The following might be missing in default production config!
        paths: {
            contentPath: path.join(process.env.GHOST_CONTENT, '/')
        }
    },

    // ### Development **(default)**
    development: {
        [...]

Deploy on Docker Cloud

Note that VIRTUAL_HOST is there for an nginx-proxy image

Docker Cloud Stackfile:

ghost:  
  image: 'ghost:latest'
  autoredeploy: true
  environment:
    - NODE_ENV=production
    - VIRTUAL_HOST=example.com
  ports:
    - '2368'
  restart: always
  volumes:
    - '/opt/ghost:/var/lib/ghost'