Skip to main content

Ghost

Here’s a concise, clear tutorial in English based on your Docker Compose setup:


Running Ghost CMS with Docker Compose

This guide explains how to deploy Ghost CMS with MySQL using Docker Compose. It’s a ready-to-go setup with persistent volumes.

Docker Compose File

Create a file named docker-compose.yml:

version: '3.3'"3" # Use Docker Compose version 3

services:
  ghost:
    image: ghost:latest6.10.3-alpine # Use the Ghost Docker image
    restart: alwayson-failure # Restart the container on failure
    environment:
      - database__client=mysql # Set Ghost's database client to MySQL
      - database__connection__host=db # Set the database host to the "db" service
      - database__connection__user=ghost # Set the database user
      - database__connection__password=portainer # Set the database password
      - database__connection__database=ghost # Set the database name
      - url=http://[YOUR_IP]:2368 # Set the base URL for the Ghost application
    volumes:
      - /srv/path/to/ghost/folder/ghost-content:/var/lib/ghost/content # Mount a volume for persistent content storage
    ports:
      - "2368:2368" # Map port 2368 from the host to port 2368 in the container
    depends_on:
      - db environment:# url:Ensure https://example.comthat database__client:the mysql"db" database__connection__host:service dbis database__connection__user:started ghostbefore database__connection__password:the ghostdbpass"app" database__connection__database:service

  ghostdbdb:
    image: mysql:8.0 # Use the MySQL Docker image
    restart: on-failure # Restart the container on failure
    volumes:
      - /home/srv/path/to/ghost/content:/var/lib/ghost/content

  db:
    image: mariadb:latest
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: your_mysql_root_password
      MYSQL_USER: ghost
      MYSQL_PASSWORD: ghostdbpass
      MYSQL_DATABASE: ghostdb
    volumes:
      - /home/ghost/mysql:folder/mysql-data:/var/lib/mysql nginx:# build:Mount context:a ./nginxvolume dockerfile:for Dockerfilepersistent restart:MySQL alwaysdata depends_on:storage
    environment:
      - MYSQL_USER=ghost ports:# Set the MySQL user
      - "80:80"MYSQL_DATABASE=ghost # Set the MySQL database name
      - "443:443"MYSQL_PASSWORD=portainer volumes:# Set the MySQL user's password
      - /etc/letsencrypt/MYSQL_ROOT_PASSWORD=portainer # Set the MySQL root password

#volumes:
#  ghost-content: # Define a named volume for Ghost content
#  mysql-data: # Define a named volume for MySQL data

Replace [YOUR_IP] with your host IP or domain (e.g., 192.168.1.104 or ghost.example.com).


Step 1: Launch Docker Compose

Run the following command in the folder containing docker-compose.yml:/etc/letsencrypt/

docker-compose up -d
/usr/share/nginx/html:/usr/share/nginx/html

This will pull the images and start both Ghost and MySQL.


Step 2: Wait for MySQL Initialization

The MySQL container needs some time to initialize. Check logs with:

docker-compose logs -f db

Wait until you see messages confirming that the database and user have been created.


Step 3: Wait for Ghost to Create Tables

Ghost will automatically create the necessary tables in the database. This can take a few minutes depending on your system. You can monitor Ghost logs:

docker-compose logs -f ghost

Look for a message like:

Ghost server started in production...
Your site is now available on http://[YOUR_IP]:2368/

Step 4: Configure Ghost

Once the containers are ready, open your browser:

  • Local: http://[YOUR_IP]:2368/ghost

  • Or via domain: https://ghost.yourdomain.tld/ghost

Follow the web interface to create your admin user and configure the site.


Notes

  • Volumes ghost-content and mysql-data ensure your content and database persist between container restarts.

  • The depends_on option ensures that MySQL starts before Ghost, but Ghost may still start before MySQL is fully ready. Patience is needed during initial setup.

  • To expose Ghost through a reverse proxy (like Nginx Proxy Manager), just point the proxy to the host IP and port 2368.