Package a PHP project with a docker image

Source: Internet
Author: User
Tags docker run

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.