We can run php application using docker. In the following steps, we are creating and running php application.
- Create a directory
$ mkdir php-docker-app
$ cd php-docker-app
2. Create a Php File (in the directory)
// index.php
<?php
echo ?Hello, Php?;
?>
3. Create a DockerFile
// Dockefile
FROM php:7.0-apache
COPY . /var/www/php
After that our project has two files like the below screen-shot :
4. Create Docker Image
docker build -t php-app .
In the below screen-shot, we are creating docker image.
Now look for the available images in the docker container.
The above screen-shot shows that the created image php-app is available.
5. Run the Docker image
Now run the docker image. The following command is used to run docker images.
$ docker run php-app
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.