Docker-Project

This is my final project to setup JOOMLA WebApp using Docker under the mentorship of Mr. VIMAL DAGA sir, under the campaign IIEC RISE.

Prerequisites :-

  • RedHat Enterprise Linux 8 , DOCKER software .

1. Starting DOCKER:

  • Use #systemctl start docker.You need to start DOCKER because it is a PRODUCT . So, before using it,you need to start docker services.

2. Download required docker images:

  • Pull MySQL image:
    • Use #docker pull mysql:5.7 to download mysql version 5.7 image to use as database server.
  • Pull JOOMLA image:
    • Use #docker pull joomla:3.9-php7.2-apache to download joomla image with php and apache web server already configured.
    • *to know more go to page: https://hub.docker.com/

3. Create a seperate volume for storage and start MySQL in one container:

  • Use #docker volume create <name of volume1> .
  • Use #docker run -dit -e MYSQL_ROOT_PASSWORD=<password of your root account> -e MYSQL_USER=<user name> -e MYSQL_PASSWORD=<password for user account> -e MYSQL_DATABASE=<name of folder inside MySQL which will be your database> -v <name of volume1>:/var/lib/mysql --name <hostname of container having mysql> mysql:5.7 .
  • To see databases created you need to install MySQL client which will send request to MySQL Server . For installing, use #yum install mysql. install mysql client mysql database

4. Create a seperate volume and start JOOMLA in another container:

  • Use #docker volume create <name of volume2> . create storage for joomla
  • Use #docker run -dit -e JOOMLA_DB_HOST=<hostname of container having mysql> -e JOOMLA_DB_USER=<user name> -e JOOMLA_DB_PASSWORD=<password for user account> -e JOOMLA_DB_NAME=<name of folder inside MySQL which will be your database> -v <name of volume2>:/var/www/html --name <container name> -p <port no. of router i.e. exposed port>:<port no. of services running inside your server> --link <hostname of container having mysql> joomla:3.9-php7.2-apache . run joomla

Now, you can see in your browser by typing <ip address>:<port no. that you have exposed>

joomla on chrome browser data added in MySQL database

5. Docker-compose:

  • Before using Docker-Compose you should install the software. For reference go to this website : https://docs.docker.com/compose/install/
  • You can create and edit this file using vim editor. For that use #vim docker-compose.yml. Remember the file name should always be docker-compose.yml. You can change but, in later. yml file yml file continued

6. Docker-compose up/down or start/stop:

  • We have copied entire infrastructure in one single file. Now it is ready to go !!! Now, you will come to know about the role of Docker. How it is so fast !!!
  • Use #docker-compose up and #docker-compose down to start and stop services respectively. docker compose up docker compose down

7. Finally , your WebApp can be seen:

TROUBLESHOOT:

  • There might be possible it is not able to connect that might be due to FIREWALL . Use #systemctl stop firewalld. Again you want to start the service use #systemctl start firewalld. but, it is not good practice to stop firewall. Instead do this,
    • Masquerading allows for docker ingress and egress #firewall-cmd --zone=public --add-masquerade --permanent
    • Specifically allow incoming traffic on port 80/443 (nothing new here) #firewall-cmd --zone=public --add-port=80/tcp #firewall-cmd --zone=public --add-port=443/tcp
    • Reload firewall to apply permanent rules #firewall-cmd --reload
    • Restart docker #systemctl restart docker
  • If JOOMLA WebApp is not opening on your desired port , maybe due to iptables . Use #iptables -P FORWARD ACCEPT .