Question: Parallel Distributed System Project objective: How to use docker-compose file to run php application In this project assignment you will be working as a group
Parallel Distributed System Project
objective: How to use docker-compose file to run php application In this project assignment you will be working as a group of 4 students to create php application using docker container
Docker-compose:
You need to install docker compose
o For Linux : sudo apt install docker compose
update doucker sudo apt-get update sudo apt-get upgrade docker-ce
update docker compose:
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/dockercompose-$(uname -s)-$(uname -m)" -o
/usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose
o Foe windows : already installed with docker .To verify the existence : dockercompose --version
Setup development environment:
Create new directory and move to it .
Create compose file inside the directory ex: nano docker-compose.yml
Inside the nano editor :
o select the Docker version you want to use :ex version 3.8
o The services you want to provide
Ex: Services:
Php-apache-environment:
o The containers name that you want to run .you can use any name .
Ex: container_name: php37.
o Container Image which version of PHP Apache you want to use.
Ex : image: php:8.0-apache
o The volume
Ex: volume: - ./php/src:/var/www/html/
o The port numbers.
ports: -8000-80
o Write this command in Terminal to download the needed library and run the container .
docker-compose up
o open local host to ensure the container is set to execute the PHP scripts
http://localhost:8000/
o From the terminal move to the directory that you create before and navigate to php file
o Create php file using nano editor :
nano index.php
inside the php file print any statement
Setup a MySQL database container
Connect php to MySQL container
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
