Build and Run PHP+MySQL Application in Docker

 

 


   Method 1 (For Better Understanding):

   Create a Common Network for PHP & MySQL container

  1.  docker network create chatbot

    PHP Container

  1.  At first clone this repo https://github.com/shawon100/RUET-ChatBot
  2. Then go to the folder. Change the host name from localhost to db and add password 1test2 in config.php
  3. Build the image 
  4.  docker build -t chatbotimage 
  5.  Finally Run the Image
  6.  docker run -d -p 5400:80 --name chatbotapp --network chatbot chatbotimage

    MySQL Container

       Pull mysql image and then Run

  1. docker pull mysql:latest

  2. docker run -d -p 3306:3306 --name db --network chatbot -e MYSQL_ROOT_PASSWORD=1test2 -e MYSQL_DATABASE=chat mysql

     

    Exec into mysql container

     

    docker exec -it db bash

     

    Login to mysql and database

     

    mysql -u root -p

     

    use chat;

     

    Run the  chat.sql from the database folder to Insert the data

     

    Go to http://localhost:5400  

     

     

    If you want to become a master in Docker for handling production grade workloads you can enroll in this course. 

     

     

     

     

     

     

     


     

     

    Method 2 (Using Docker Compose):  

     

    1.  At first clone this repo https://github.com/shawon100/RUET-ChatBot
    2. Then go to the folder. Change the host name from localhost to db and add password 1test2 in config.php
    3. Then run the docker-compose.yml using this command
    4. docker-compose up -d 

     

     

     

  3.   Video Tutorial

     


     

Download Coding Interview Book and Get More Tutorials for Coding and Interview Solution: Click Here

Download System Design Interview Book and Get More Tutorials and Interview Solution: Click Here

Do you need more Guidance or Help? Then Book 1:1 Quick Call with Me: Click Here

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

1 comments: