Skip to main content

Command Palette

Search for a command to run...

create a blogging platform using docker-compose

Published
β€’2 min read
create a blogging platform using docker-compose
S

Hi! My name is Safia Khatoon. I am complete my Bachelors in Technology from RTC Institute Of Technology. My specialisation in Computer Science and Engineering.I love contributing to Open Source with the help of the skills I gain.

Also, I'm working on my YouTube Channel as well where I teach about DevOps tools and make technical content. You can have a look at it through my profile.

Feel free to reach out to me! I'd be happy to connect with you.

  1. Install Docker and Docker Compose on your machine.

  2. Create a new directory for your project and navigate into it.

  3. Create a new file called "docker-compose.yml" and open it in a text editor.

  4. Define the services that you want to run in your Docker Compose file.

codeversion: '3'

services:
  db:
    image: mysql:5.7
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: example_root_password
      MYSQL_DATABASE: wordpress
      MYSQL_USER: example_user
      MYSQL_PASSWORD: example_password

  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    ports:
      - "8000:80"
    restart: always
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: example_user
      WORDPRESS_DB_PASSWORD: example_password
      WORDPRESS_DB_NAME: wordpress
    volumes:
      - wp_data:/var/www/html

volumes:
  db_data:
  wp_data:

In this example, we have two services: db and wordpress. The db service is running a MySQL database, and the wordpress service is running the WordPress application.

The db service is using the mysql:5.7 image and creating a named volume db_data to store the database data. It also sets some environment variables for the MySQL root password, database name, and user credentials.

The wordpress service depends on the db service, and is using the wordpress:latest image. It maps port 8000 on the host to port 80 in the container, and creates a named volume wp_data to store the WordPress application data.

The wordpress service also sets some environment variables to configure the WordPress application to use the MySQL database created by the db service.

You can save this file as docker-compose.yml in a directory and then run docker-compose up -d to start the WordPress blog in the background.

GitHub Link : https://github.com/Safiakhatoon767/blogging-platform

P

Great Article πŸ‘πŸ‘πŸ‘πŸ‘πŸ‘

More from this blog

Untitled Publication

136 posts