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" # Use Docker Compose version 3
services:
ghost:
image: ghost:6.10.3-alpine # Use the Ghost Docker image
restart: on-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 # Ensure that the "db" service is started before the "app" service
db:
image: mysql:8.0 # Use the MySQL Docker image
restart: on-failure # Restart the container on failure
volumes:
- /srv/path/to/ghost/folder/mysql-data:/var/lib/mysql # Mount a volume for persistent MySQL data storage
environment:
- MYSQL_USER=ghost # Set the MySQL user
- MYSQL_DATABASE=ghost # Set the MySQL database name
- MYSQL_PASSWORD=portainer # Set the MySQL user's password
- 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.104orghost.example.com).
Step 1: Launch Docker Compose
Run the following command in the folder containing docker-compose.yml:
docker-compose up -d
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-contentandmysql-dataensure your content and database persist between container restarts. -
The
depends_onoption 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.