SQLite Compatibility for Ghost 5.x on Docker

Recently, I wanted to update my Ghost blog instance. Upon updating the Docker image, I was greeted with an error stating that it could not connect to the database. After some investigation, I discovered that the default database had been changed from SQLite to MySQL. This presents an issue for me, as I prefer not to set up a MySQL instance exclusively for my blog.

After digging some more, I discovered that while SQLite isn't the main focus anymore, it still sort of works. To make it work, you have to tweak a few settings.

The solution

Here's what you need to do to get SQLite working with Ghost 5.x on Docker. I did this in my docker-compose file:

services:
  ghost:
    image: ghost:latest
    container_name: ghost
    volumes:
      - .:/var/lib/ghost/content
      - /etc/localtime:/etc/localtime:ro
    environment:
      database__client: sqlite3
      database__connection__filename: content/data/ghost.db
      database__useNullAsDefault: true
      database__debug: false
docker-compose.yaml

The variable database__connection__filename should point to your SQLite db file.

It's worth noting that officially, using SQLite for your main Ghost setup isn't recommended. Things might break in the future if Ghost updates and SQLite can't keep up. They remind you about this every time you go to the admin panel.

In short, by adjusting these settings, you can give SQLite another shot with Ghost 5.x on Docker. Just remember that although this isn't the ideal setup, it could work until Ghost and SQLite part ways for good.