Selfhosting Ghost - the easiest way with v5.8.3

Containers Jul 5, 2022

Ghost is the service I use to create this site. It is lightweight and pretty straightforward to use. It offers in-built membership, email and paywall tools (not that I specifically use any of them) but also offers powerful and free out-of-the-box themes to change up your look. If they aren't enough, then you can either browser the paid themes market place, OR you can modify the style sheets yourself - yup, it makes those 100% available to you, so with a little bit of html and css knowhow, you can make your site completely your own.

The thing is, if you follow the official dockerhub guide or the bitnami github repo then it's not the easiest of tools to set up. Assuming you want this blog to be exposed to the outside world and therefore have your own domain ready to go, I'm going to show you just how simple this can be to get up and running using the inbuilt SQLite database.

💡
Note that Ghost discontinued SQlite support in version 5.9.4. This walkthrough uses 5.8.3 which is the latest manifested version still available with SQlite support. If you want to have the most up to date version, you will need to follow a guide which makes use of separate database containers

Prerequisites

You will need to have, be able to do, or provide the items below:

  1. Docker and docker-compose installed on your machine
  2. The ability to SSH / use CLI/terminal on your machine, or use Portainer to spin up your stacks
  3. Some sort of access and relevant permissions to manage and create new directories
  4. A Fully Qualified Domain Name (FQDN, e.g. pointtosource.com)
  5. A reverse proxy already set up for the service you want, on its own docker network (for instance called proxy) with the relevant SSL certificate(s) (check out my SWAG article for some info on how to do that if you haven't already)

Creating the file structure

  • Navigate to your docker directory and create a folder called ghost.

Done.


Creating your docker-compose and .env files

  • Inside your ghost directory, create a file called docker-compose.yml, then copy in the following:
services:
  ghost:
    image: ghost:5.8.3
    container_name: ghost # change as necessary
    ports:
      - '2368:2368' # change before the `:` as necessary
    volumes:
      - .:/var/lib/ghost/content
      - /etc/localtime:/etc/localtime:ro
    # uncomment below to connect it to your own network  
    #networks:
      #- [add your network name here]
    restart: unless-stopped
The totality of our docker-compose file, make sure you make the relevant modifications and remove any [ ] brackets

That's it, there's no .env file.

you can copy paste the above to your Portainer stack as well

Spinning up the container

  • From your ghost directory in SSH type the following command:
docker-compose up -d

OR

  • In Portainer, create the stack

Accessing your new Ghost container

You should now be able to access the initial set up stages for your new Ghost container by going to your browser and typing in http://yourMachineIP:2368/ghost (if you changed the port in the compose file, make sure it's reflected here).

You should see a screen like this:

Setting up your Ghost admin account

Once you've filled in your new credentials (don't forget to save them!) you will see a screen which offers you a couple of next steps options:

And you're off! Explore and take a look around, and enjoy creating your very own website and/or blog!


If you plan to set up a reverse proxy

A slight change needs to be made to the docker-compose.yml file to tell ghost that an external URL is suitable for access. Add the below environment variable (where environment is in the same column as image, container_name etc.):

    environment:
    	URL: https://sub.yourdomain.com      
make sure you change the URL to match your own domain and access

You will now be able to set up your reverse proxy and access your ghost setup and site from the domain.

💡
Note that until you set up your reverse proxy (either with SWAG, NPM, Traefik etc.) this change will break your IP:port access, as it will try and forward that to this new URL

Tips and tricks for those who self-host Ghost Blog
Coding tips and tricks to get the most out of your ghost theme, using CSS, scripts and the built-in handlebars language of ghost
Swag, Authelia and Reverse Proxies
A step-by-step walkthrough to self-host your Reverse Proxy with SWAG, and providing SSO and 2FA security using Authelia, all in docker
Portainer - Easy Container Management for Docker
A step-by-step docker walkthrough to installing and configuring Portainer, your one-stop container-management resource

PTS

PTS fell down the selfhosted rabbit hole after buying his first NAS in October 2020, only intending to use it as a Plex server. Find him on the Synology discord channel https://discord.gg/vgSq5pcT

Have some feedback or something to add? Comments are welcome!

Please note comments should be respectful, and may be moderated