π2-ππ’ππ« ππ©π©π₯π’ππππ’π¨π§ ππ¬π’π§π ππ¨ππ€ππ« ππ¨π¦π©π¨π¬π ππΆππ΅ πͺπΌπΏπ±π½πΏπ²ππ & MySπΎπΉ π

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.
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.
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
