In this article we’re going to build one new docker image with Apache and PHP installed and one php file for test.
Create a directory called “build”:
# mkdir ˜/build
Change to directory “build”:
# cd ˜/build
Create a new file called Dockerfile with the following content:
FROM centos MAINTAINER Daniel Nascimento RUN yum update -y RUN yum install httpd php -y ADD index.php /var/www/html/ CMD /usr/sbin/apachectl -D FOREGROUND EXPOSE 80
In the same directory create another file called index.php with the following content:
<?php phpinfo(); ?>
Finally it’s time of build our new image.
# docker build -t user/httpd .
Now we have a new image with apache and php installed. Then let’s create a new container using this image:
# docker run -t -i -p 80:80 user/httpd
To access our new container in your browser type the URL:
http://your-host-ip/
That’s it! 🙂