Deploying Ghost With Docker

Docker is a new and upcoming process for deploying compartmentalized servers. A common use case is to have a container for each different component of your web server stack. For example, you could have a database container, web server container, memcache container, etc.

The Docker team has produced an official container that is prebuilt with Ghost in it.

How to Install Docker

Docker is supported on many popular Linux distributions. Check the Docker documentation for the instructions on installing Docker on your preferred operating system.

Now that Docker is installed you will need to pull down the Ghost container from the Docker repository. To do this, you will run the following command and Docker will store the container in your local repository (command can be run from any directory):

docker pull ghost

Once the download is complete you can start the Ghost Docker container with:

docker run -d -p 80:2368 ghost

You can now access Ghost in your web browser at http://{hostname}, where {hostname} is the IP address or domain name of your Docker server.

Additional Options

When starting the Ghost container you also have the option to overwrite the location of Ghost's config.js file, theme directory, and data directory. This will allow you to store the important data outside of your Docker container in a persistent location. This is the recommended way to run a Ghost container so that you can preserve your data when you update Ghost.

The command to start your Docker container with the data outside of Docker looks like this:

docker run -d -p 80:2368 -v /path/to/ghost/blog:/var/lib/ghost ghost

where /full/path/to/your/directory is an absolute path to a directory that can contain your

  • config.js
  • content/data
  • content/themes

For example, if your created a data directory at the root level of your server you could place your config.js, themes, and database in /data and your directory structure would look like this:

├── config.js
└── content
    ├── data
    │   └── ghost.db
    └── themes
        └── ghostentista

The Docker container for Ghost is still young but has already proven to be a very valuable tool to me. If you have any question about getting setup with Docker, or find any areas where you think the Ghost container could be improved please let us know, we have been working with the author to improve a couple of things.