Step 1: Download required images
docker pull ramansharma95/webapp
docker pull ramansharma95/mysql
Step 2: Create a webapp container with network as host and DO NOT DO a port forwarding on port number 80 as per custom network cause this assignment is run on host network.
docker container run -it --name web --network host -d ramansharma95/webapp
Go to browser and check that you are able to see the default web page. localhost:80
Step 3: Go inside the container (web) and check the code for index.php cause you will need to edit it a little.
docker exec -it web bash
vi /var/www/html/index.php
docker pull ramansharma95/mysql
Step 2: Create a webapp container with network as host and DO NOT DO a port forwarding on port number 80 as per custom network cause this assignment is run on host network.
docker container run -it --name web --network host -d ramansharma95/webapp
Go to browser and check that you are able to see the default web page. localhost:80
Step 3: Go inside the container (web) and check the code for index.php cause you will need to edit it a little.
docker exec -it web bash
vi /var/www/html/index.php
edit the username from db to host ip address (192.168.33.10).
# you will find that in the index.php, it has connection configs to connect to a server named 'db' but need to edit to host ip address cause its on the same network and also the required username and password to enter that server.
Step 4:- Create a db container with network defined (note this does not require port forwarding)
docker container run -it --name db --network host -d ramansharma95/mysql
Step 5:- Go inside the container (db).
docker exec -it db bash
5.2 connect to mysql with username root and password whizlabs
mysql -uroot -pwhizlabs
5.3 Create a database company
show databases;
create database company;
show databases;
5.4 Create a table employee with name and mobile field.
use company;
create table employee ( name varchar(30), mobile varchar(30) );
5.5 Show all the records in this table
select * from employee;
Step 6: Go to browser and add some employees details in the webpage and check again records in employee table, it should have those records added.
docker container run -it --name db --network host -d ramansharma95/mysql
Step 5:- Go inside the container (db).
docker exec -it db bash
5.2 connect to mysql with username root and password whizlabs
mysql -uroot -pwhizlabs
5.3 Create a database company
show databases;
create database company;
show databases;
5.4 Create a table employee with name and mobile field.
use company;
create table employee ( name varchar(30), mobile varchar(30) );
5.5 Show all the records in this table
select * from employee;
Step 6: Go to browser and add some employees details in the webpage and check again records in employee table, it should have those records added.
Step 7: Show all the records in this table.
select * from employee;
No comments:
Post a Comment