Docker:
Docker is the most revolutionized technology in virtualization world nowadays. Docker is actually an open source project which provides container technology. A container is a lightweight VM(virtual machine) or a process which allows us to install Linux based applications inside it. The container doesn’t have its own Kernel, RAM, CPU and Disk but it uses the underlying OS kernel, RAM, CPU cores and Disk.
In my this blog, I'm going to demonstrate, How to setup LAMP Stack on Docker system.
We will Create 3 Container as follow:
- Apache + PHP Container
- MySQL Container
- PhpMyAdmin Container
- Docker
- Docker-compose
Step 1- Install Docker:
Before we provision our LAMP Stack, we need docker installed on your host. Follow my previous blog for installing Docker.
https://linuxhowtoguide.blogspot.com/2018/08/how-to-install-docker-in-ubuntu-1604-lts.html
Step 2- Install Docker-compose:
Step 3- Clone git repository on your local system and change directory
Run the following command to clone git repository
Change Directory
Step 4- Create Folder to mount with Apache and MySQL container
Before, we provision our LAMP container environment. First, We need to complete some prerequisites. 1-We will setup Two Directories, One for DocumentRoot and Second for MySQL database directory. Run the following command to setup two directories.
Copy phpinfo.php to DocumentRoot
Once Directory setup successfully, we can proceed to provision LAMP Container stack
Step 5- Setup Container for LAMP Stack
To provision LAMP stack run following command.
Validate Created Container:
You will see three up and running container.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
326da5972785 phpmyadmin/phpmyadmin "/run.sh supervisord…" About an hour ago Up About an hour 9000/tcp, 0.0.0.0:8080->80/tcp docker-lamp_phpmyadmin_1
c1a700d81c42 amarsingh3d/apache2.4-php7.2 "/bin/sh -c '/usr/sb…" About an hour ago Up About an hour 0.0.0.0:80->80/tcp docker-lamp_www_1
7480657c8ced mysql:5.6 "docker-entrypoint.s…" About an hour ago Up About an hour 0.0.0.0:3306->3306/tcp docker-lamp_db_1
All Three Containers are up and running.
Step 6- Verify Container and Services:
In order to verify Apache container, check your Docker host IP address and access IP Address in the browser. In my case, My IP address is following
Verify PhpMyAdmin Access
To access PhpMyAdmin go to browser and access Docker host IP with port 8080
http://10.0.1.170:8080/
To access PhpMyAdmin go to browser and access Docker host IP with port 8080
http://10.0.1.170:8080/
We have successfully setup LAMP stack on Docker host.
Thanks man!!!! its helped me...
ReplyDeleteGreat work.
ReplyDeleteCan you describe how to use apache and php in a separate containers and how they will communicate?