Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Deploy Ghost With Docker

Ghost is a markdown blogging platform that allows one to easily post content that displays well on any screen size, such as a mobile phone.

Docker allows one to easily deploy applications such as Ghost without having to spend lots of time installing packages and reading installation instructions. This tutorial assumes you already have a docker host, or know how to install docker.


Execute the following script to pull down the latest ghost docker image, and set up a directory to store data.

if ! [ -n "$BASH_VERSION" ];then
    echo "this is not bash, calling self with bash....";
    SCRIPT=$(readlink -f "$0")
    /bin/bash $SCRIPT

# Pull down the ghost image
docker pull ghost:latest

# Set vars
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

# Create volume area to store state and create base config there
mkdir -p $DATA_DIR

echo '{
  "url": "",
  "server": {
    "port": 2368,
    "host": ""
  "database": {
    "client": "sqlite3",
    "connection": {
      "filename": "/var/lib/ghost/content/data/ghost.db"
  "mail": {
    "transport": "Direct"
  "logging": {
    "transports": [
  "process": "systemd",
  "paths": {
    "contentPath": "/var/lib/ghost/content"
}' > $DATA_DIR/config.json

Once run, you will have a folder called ghost_volume in your home directory. Inside that folder will be a folder called "content" that will store is all the content for the blog, and a file called config.js which will be the configuration file for the blog.

Update the config.js file within the ghost_volume directory and change the line:

"url": "",

... so that it points to your site's actual hostname or IP address.

Start the Container

Now you are ready to start your container. I recommend copy-pasting the script below into a file called that you can execute if you ever need to manually start your blog again.

# Set vars
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

# Stop and remove the existing container if
# it is already running.
docker kill $CONTAINER_NAME

docker run \
-d \
--restart=always \
-p 80:2368 \
-v $DATA_DIR/content:/var/lib/ghost/content \
-v $DATA_DIR/config.json:/var/lib/ghost/config.production.json \

Register Yourself

Navigate to your blog's IP or hostname and you should see the following screen: Now add /admin to the end of the URL and fill in the provided form to register yourself as the administrator, in order to make new posts.

Updating ghost

Whenever you want to update ghost, just run:

docker pull ghost:latest

Then run the start-container script from above to use the latest image that you just pulled.


You have now seen how to setup your own blog using Ghost and Docker and should be able to navigate the menus on your own to create new posts. Now you may be interested in finding out how to add comments to your blog.

Last updated: 8th August 2020
First published: 16th August 2018