Summary: Sometimes we need to package a PHP project into a Docker image, which is described here
Idea: We PHP and Apache combine an image to implement PHP project Access, MySQL is a separate mirror
Steps:
1. First of all, we test the local PHP project is not available, after all, put on the server after the test is not very convenient. We then import the PHP project into the server and create a new index.php,myapp/index.php content in the project directory:
<?php
echo "Hello";
?>
2. Create a new Dockerfile file in the same directory as the project content:
From Php:5.6-apache
RUN Docker-php-ext-install mysqli
ADD myapp/var/www/html
Simply explain the image we are based on is Php:5.6-apache, then configure MySQL extension, copy the project to the container's var/www/html directory, here will only be responsible for the contents of MyApp, the MyApp itself directory does not copy
3. Continue to create the mirrored Docker build-t MyApp in the same directory as the project.
4. Place the image in a container: Docker run-d-P 80:80 MyApp
5. Enter the server IP in the browser and the page displays Hello
The PHP configuration is finished, then test your own project.
Package a PHP project with a docker image