Skip to content

Docker Guide: Deploying Ghost Blog with MySQL and Traefik with Docker

Netcloud24
Cloud Infrastructure Expert
HOSTING H1

Free web hosting H1

5 GB of storage and SSL for a small website or WordPress project.

Explore hosting H1
WINDOWS VPS + RDS

Run Windows applications remotely

Windows Server 2022 or 2025 and RDS CALs included in the plan. Choose resources and user capacity for your business.

Explore Windows VPS
NetCloud24 Expert Guides Open the dedicated video page

Video transcript: NetCloud24 Expert Guides. Practical knowledge for a reliable cloud. Cloud and VPS expertise, security, performance, and step-by-step tutorials. Learn, deploy, and keep building with NetCloud24.

 

Ghost is a popular, open-source blogging platform that is designed for simplicity and speed. Using Docker, you can easily deploy Ghost with a MySQL database and Traefik for reverse proxying and automatic SSL management. Whether you’re hosting your blog on a or any other server provider, this guide will walk you through the steps of setting up Ghost with MySQL and Traefik using Docker.

Prerequisites

Before starting, ensure you have the following:

Step 1: Set Up Docker Compose File

Create a directory for your Ghost blog setup and navigate to it:

mkdir ghost-mysql-traefik
cd ghost-mysql-traefik

Create a docker-compose.yml file in this directory:

Visual overview of Docker Guide: Deploying Ghost Blog with MySQL and Traefik with Docker
Visual overview: Docker Guide: Deploying Ghost Blog with MySQL and Traefik with Docker
nano docker-compose.yml

Add the following configuration:

version: '3'

services:
  ghost:
    image: ghost:latest
    container_name: ghost-blog
    restart: always
    depends_on:
      - db
    environment:
      url: http://your-domain.com
      database__client: mysql
      database__connection__host: db
      database__connection__user: ghost
      database__connection__password: yourpassword
      database__connection__database: ghost
    volumes:
      - ./ghost/content:/var/lib/ghost/content
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.ghost.rule=Host(`your-domain.com`)"
      - "traefik.http.services.ghost.loadbalancer.server.port=2368"
    networks:
      - ghost-network

  db:
    image: mysql:5.7
    container_name: ghost-db
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: yourpassword
      MYSQL_DATABASE: ghost
      MYSQL_USER: ghost
      MYSQL_PASSWORD: yourpassword
    volumes:
      - ./ghost/db:/var/lib/mysql
    networks:
      - ghost-network

  traefik:
    image: traefik:v2.3
    container_name: traefik
    restart: always
    command:
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.myresolver.acme.tlschallenge=true"
      - "--certificatesresolvers.myresolver.acme.email=youremail@example.com"
      - "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
      - "./letsencrypt:/letsencrypt"
    networks:
      - ghost-network

networks:
  ghost-network:
    driver: bridge

Replace your-domain.com and yourpassword with your actual domain and password.

Step 2: Set Permissions for Docker Volumes

Ensure that the directories for Ghost content and MySQL data have the correct permissions:

mkdir -p ghost/content ghost/db letsencrypt
sudo chown -R 1000:1000 ghost/content ghost/db

Step 3: Launch the Docker Containers

Run the following command to start the Ghost, MySQL, and Traefik services:

docker-compose up -d

This will download the required images and set up your Ghost blog, MySQL database, and Traefik for reverse proxying and SSL management.

Key topics covered in Docker Guide: Deploying Ghost Blog with MySQL and Traefik with Docker
Key topics covered in this NetCloud24 guide.

Step 4: Access Your Ghost Blog

Once the services are up and running, open your web browser and navigate to http://your-domain.com to access your Ghost blog. You will be greeted by the Ghost setup page, where you can create your admin account and configure your blog.

Step 5: Verify SSL with Traefik

Traefik automatically handles obtaining an SSL certificate from Let’s Encrypt for your domain. To verify that SSL is working, visit https://your-domain.com in your browser, and check that the connection is secure.

Conclusion

By following these steps, you have successfully deployed a Ghost blog with MySQL and Traefik using Docker. Whether you’re hosting your site on a , Microsoft SQL VPS Windows, or another Windows VPSVirtual Private Server Hosting solution, this setup ensures your Ghost blog is fast, secure, and easy to manage with Docker.

Docker Guide: Deploying Ghost Blog with MySQL and Traefik with Docker
Docker Guide: Deploying Ghost Blog with MySQL and Traefik with Docker
Explore more

More on this topic

Netcloud24
Netcloud24
Cloud Infrastructure Expert · NetCloud24

Comments are closed.

Docker Guide: Deploying Ghost Blog with MySQL and Traefik with Docker

Netcloud24
Cloud Infrastructure Expert
HOSTING H1

Free web hosting H1

5 GB of storage and SSL for a small website or WordPress project.

Explore hosting H1
WINDOWS VPS + RDS

Run Windows applications remotely

Windows Server 2022 or 2025 and RDS CALs included in the plan. Choose resources and user capacity for your business.

Explore Windows VPS
NetCloud24 Expert Guides Open the dedicated video page

Video transcript: NetCloud24 Expert Guides. Practical knowledge for a reliable cloud. Cloud and VPS expertise, security, performance, and step-by-step tutorials. Learn, deploy, and keep building with NetCloud24.

 

Ghost is a popular, open-source blogging platform that is designed for simplicity and speed. Using Docker, you can easily deploy Ghost with a MySQL database and Traefik for reverse proxying and automatic SSL management. Whether you’re hosting your blog on a or any other server provider, this guide will walk you through the steps of setting up Ghost with MySQL and Traefik using Docker.

Prerequisites

Before starting, ensure you have the following:

Step 1: Set Up Docker Compose File

Create a directory for your Ghost blog setup and navigate to it:

mkdir ghost-mysql-traefik
cd ghost-mysql-traefik

Create a docker-compose.yml file in this directory:

Visual overview of Docker Guide: Deploying Ghost Blog with MySQL and Traefik with Docker
Visual overview: Docker Guide: Deploying Ghost Blog with MySQL and Traefik with Docker
nano docker-compose.yml

Add the following configuration:

version: '3'

services:
  ghost:
    image: ghost:latest
    container_name: ghost-blog
    restart: always
    depends_on:
      - db
    environment:
      url: http://your-domain.com
      database__client: mysql
      database__connection__host: db
      database__connection__user: ghost
      database__connection__password: yourpassword
      database__connection__database: ghost
    volumes:
      - ./ghost/content:/var/lib/ghost/content
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.ghost.rule=Host(`your-domain.com`)"
      - "traefik.http.services.ghost.loadbalancer.server.port=2368"
    networks:
      - ghost-network

  db:
    image: mysql:5.7
    container_name: ghost-db
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: yourpassword
      MYSQL_DATABASE: ghost
      MYSQL_USER: ghost
      MYSQL_PASSWORD: yourpassword
    volumes:
      - ./ghost/db:/var/lib/mysql
    networks:
      - ghost-network

  traefik:
    image: traefik:v2.3
    container_name: traefik
    restart: always
    command:
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.myresolver.acme.tlschallenge=true"
      - "--certificatesresolvers.myresolver.acme.email=youremail@example.com"
      - "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
      - "./letsencrypt:/letsencrypt"
    networks:
      - ghost-network

networks:
  ghost-network:
    driver: bridge

Replace your-domain.com and yourpassword with your actual domain and password.

Step 2: Set Permissions for Docker Volumes

Ensure that the directories for Ghost content and MySQL data have the correct permissions:

mkdir -p ghost/content ghost/db letsencrypt
sudo chown -R 1000:1000 ghost/content ghost/db

Step 3: Launch the Docker Containers

Run the following command to start the Ghost, MySQL, and Traefik services:

docker-compose up -d

This will download the required images and set up your Ghost blog, MySQL database, and Traefik for reverse proxying and SSL management.

Key topics covered in Docker Guide: Deploying Ghost Blog with MySQL and Traefik with Docker
Key topics covered in this NetCloud24 guide.

Step 4: Access Your Ghost Blog

Once the services are up and running, open your web browser and navigate to http://your-domain.com to access your Ghost blog. You will be greeted by the Ghost setup page, where you can create your admin account and configure your blog.

Step 5: Verify SSL with Traefik

Traefik automatically handles obtaining an SSL certificate from Let’s Encrypt for your domain. To verify that SSL is working, visit https://your-domain.com in your browser, and check that the connection is secure.

Conclusion

By following these steps, you have successfully deployed a Ghost blog with MySQL and Traefik using Docker. Whether you’re hosting your site on a , Microsoft SQL VPS Windows, or another Windows VPSVirtual Private Server Hosting solution, this setup ensures your Ghost blog is fast, secure, and easy to manage with Docker.

Docker Guide: Deploying Ghost Blog with MySQL and Traefik with Docker
Docker Guide: Deploying Ghost Blog with MySQL and Traefik with Docker
Explore more

More on this topic

Netcloud24
Netcloud24
Cloud Infrastructure Expert · NetCloud24

Comments are closed.