Skip to content

Latest commit

 

History

History

backend_frontend_comb_hands_on

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Basics of Using Two Applications in Containerized Form

Run a wordpress container

docker run -d -p 8094:80 -e WORDPRESS_DB_PASSWORD=password -d --name wordpress saiakhil2012/wordpress

Check the exposed port

Try to Login

Give Basic Information and Press "Install Wordpress" Button

Wait!!! Something is not right!!! It says Database Connection Error
Because wordpress is expecting for a database but it is not present. 
So, Let us create a mysql container and try to provide it to wordpress container

Remove the old containers

Let us create mysql container first

docker run --name wordpressdb -p 8095:3306 -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=wordpress -d saiakhil2012/mysql

Now Let us create the Wordpress Container

docker run -p 8099:80 -e WORDPRESS_DB_PASSWORD=password -d --name wordpress --link 
wordpressdb:mysql  saiakhil2012/wordpress

Now check the exposed port 8099 and Try Installing

This time it installs

Now let us see Posts Section

There is a Hello World Post

Let us get into the mysql container and edit the post content

docker exec -it wordpressdb /bin/bash

Check the mysql process

ps -ef| grep mysql

Use mysql

mysql -u root -p
use wordpress;
show tables;
describe wp_posts;
select post_content from wp_posts where post_content like "Welcome to Wordpress%";
update wp_posts set post_content="Welcome to Workshop powered by Huawei" where post_content like "Welcome to Wordpress%";
select post_content from wp_posts where post_content like "Welcome to%";
Check the updated Post Content at the exposed port

Try It Out

Other way round also works (Change in Frontend and Backend it will get reflected)