πŸš€2-π“π’πžπ« 𝐀𝐩𝐩π₯𝐒𝐜𝐚𝐭𝐒𝐨𝐧 𝐔𝐬𝐒𝐧𝐠 πƒπ¨πœπ€πžπ« π‚π¨π¦π©π¨π¬πž π˜„π—Άπ˜π—΅ π—ͺπ—Όπ—Ώπ—±π—½π—Ώπ—²π˜€π˜€ & MyS𝗾𝗹 πŸš€

Piyush KabraPiyush Kabra
2 min read
version: "3.8"
services:
 db:  #One Service Is Database which is of MySql
    image: mysql:latest
    container_name: mydb1
    networks:
      - lwnet
    volumes:
      - /data:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=redhat
      - MYSQL_DATABASE=blogdb
      - MYSQL_USER=piyush
      - MYSQL_PASSWORD=redhat
 wp: #One service is of Frontend + Backend Which is of Wordpress
    depends_on:
      - db
    image: wordpress:latest
    container_name: wp1
    networks:
      - lwnet
    ports:
      - 8025:80
    environment:
      - WORDPRESS_DB_HOST=mydb1
      - WORDPRESS_DB_USER=piyush
      - WORDPRESS_DB_PASSWORD=redhat
      - WORDPRESS_DB_NAME=blogdb
networks: # and we wrap these two services inside a network
  lwnet:
    driver: bridge

This was docker-compose.yml file, which has to be inside a folder and we have to run it from there using

β€œdocker-compose up -d”

If we don’t use -d option then the MySQL container will start running in foreground and it’s output will be on the screen and we can’t use the terminal then, and if we do ctrl+c then the containers will be stopped.

No alternative text description for this image

No alternative text description for this image

Take the Port Number of WordPress:latest β€”> 8081 & Public IP of your machine.

Type :- 192.168.29.56:8081 on your browser, will see something like this

Then mention the details and do remaining things, after that just write a blog and publish it.

No alternative text description for this image

So at last, you will see a blog hosted on your localhost IP address.

0
Subscribe to my newsletter

Read articles from Piyush Kabra directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Piyush Kabra
Piyush Kabra