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.


Create a docker-compose.yaml file with the following content:

version: '3.1'


    container_name: ghost
    image: ghost:5.66.1
      - db
    restart: always
      - "80:2368"
      - ./ghost-content:/var/lib/ghost/content
      # see
      database__client: mysql
      database__connection__host: db
      database__connection__user: ghost
      database__connection__password: ${GHOST_DB_PASSWORD}
      database__connection__database: ghost

      # this url value is just an example, and is likely wrong for your environment!
      url: ${APP_URL}

      NODE_ENV: production

    container_name: db
    image: mysql:8.0
    restart: always
#    ports:
#      - "3306:3306"
      - ./mysql-data:/var/lib/mysql
      MYSQL_DATABASE: ghost
      MYSQL_USER: ghost

Then create a .env file at the same level as your docker-compose.yaml file with the following content:

# Specify the public URL for your site. This should include http:// or https:// based on your setup
# (you may be behind a terminating SSL proxy).

# Specify a random password for your database.

Then start everything up:

docker compose up

Register Yourself

Now go to your blog's URL,.but with /ghost on the end, fill in the new user form, and then it will kick you through to the ghost dashboard.

Updating ghost

Whenever you want to update ghost, just update the version in your docker-compose file before running docker-compose down and up.


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.


Old Original Post (For Posterity)

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.

Last updated: 12th November 2023
First published: 16th August 2018