Home » Docker Php Example

Docker Php Example

by Online Tutorials Library

Docker Php Application Example

We can run php application using docker. In the following steps, we are creating and running php application.

  1. Create a directory
  2. Create a directory to organize files by using following command.

    See, screen shot of the above command.

    Docker Php application 1

  3. Create a Php File
  4. // index.php

  5. Create a DockerFile
  6. // Dockefile

    After that our project has two files like the below screen-shot.

    Docker Php application 2

  7. Create Docker Image
  8. In the below screen-shot, we are creating docker image.

    Docker Php application 3

    Now look for the available images in the docker container.

    Docker Php application 4

    The above screen-shot shows that the created image php-app is available.

  9. Run the Docker image
  10. Now run the docker image. The following command is used to run docker images.

    Docker Php application 5

    We can see that our docker image is running and output is shown to the browser. This image is running on the 172.17.0.2 ip.

    Output:

    Docker Php application 6


You may also like