Docker Compose for Ghost CMS

Ghost publishing platform with MySQL. Modern, open-source headless CMS.

ghost cms mysql blog
compose.yaml
services:
  ghost:
    image: ghost:5
    ports:
      - target: 2368
        mode: ingress
    environment:
      - url=https://example.com
      - database__client=mysql
      - database__connection__host=db
      - database__connection__database=ghost
      - database__connection__user=ghost
      - database__connection__password=${database__connection__password}
    healthcheck:
      test:
        - CMD
        - curl
        - -f
        - http://localhost:2368/ghost/api/v4/admin/site/
      interval: 30s
      timeout: 10s
      retries: 3
    depends_on:
      - db
    deploy:
      resources:
        reservations:
          cpus: "0.5"
          memory: 512M
    restart: unless-stopped
  db:
    image: mysql:8
    ports:
      - target: 3306
        mode: host
    environment:
      - MYSQL_DATABASE=ghost
      - MYSQL_USER=ghost
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
    healthcheck:
      test:
        - CMD
        - mysqladmin
        - ping
        - -h
        - localhost
      interval: 10s
      timeout: 5s
      retries: 5
    deploy:
      resources:
        reservations:
          cpus: "0.5"
          memory: 256M
    restart: unless-stopped

Services

  • ghost ghost:5
  • db mysql:8

Deploy

$ npx defang@latest compose up

Learn more about Defang