Skip to main content

Build a Ghost Blog with Docker Compose

Updated 1 min readMarkdown
Build a Ghost Blog with Docker Compose

In this blog, we will create a Ghost Blog using Docker Compose.

Docker Quest - Challenge 5.png

Pre-requisites:

  • Docker pre-installed

  • User with sudo access

Steps:

Create a Docker Compose file docker-compose.yml in the root directory. You will create two services: a Ghost Blog service and a MySQL service. Below is the code:

version: "3"
services:
  ghost:
    container_name: ghost-blog
    image: ghost:1-alpine
    restart: always
    environment:
      - database__client=mysql
      - database__connection__host=mysql
      - database__connection__user=root
      - database__connection__password=P4sSw0rd0!
      - database__connection__database=ghost
    ports:
      - 80:2368
    volumes:
      - ghost-volume:/var/lib/ghost
    depends_on:
      - mysql

  mysql:
    container_name: ghost-db
    image: mysql:5.7
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=P4sSw0rd0!
    volumes:
      - mysql-volume:/var/lib/mysql


volumes:
  ghost-volume: {}
  mysql-volume: {}

Run docker-compose up -d to deploy the defined services.

Once completed, you can run docker ps to list the deployed containers as below:

image.png

You can then access the ghost blog from your web browser using your public IP address!

80 views

About the author

No comments yet. Be the first to comment.

More from this blog