Forum Navigation
You need to log in to create posts and topics.

Create HTTPD / PHP Docker – CentOS7 – Include Contents and httpd.conf


User wants to create docker container with httpd, PHP and various modules and for maximum portability also wants to copy the configuration file the contents.


Create a file called Dockerfile in the directory for the build (or download the docker file and rename to Docker without extension ) and copy this contents

FROM centos:7

# Install Apache
RUN yum -y update
RUN yum -y install httpd httpd-tools

# Install EPEL Repo
RUN rpm -Uvh \
&& rpm -Uvh

# Install PHP
RUN yum -y install php72w php72w-bcmath php72w-cli php72w-common php72w-gd php72w-intl php72w-ldap php72w-mbstring \
php72w-mysql php72w-pear php72w-soap php72w-xml php72w-xmlrpc

# Copy Apache Configuration to etc directory
ADD /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf
#ADD /etc/httpd/conf.d/tracston.conf /etc/httpd/conf.d/tracston.conf

## Copy directory contents to container
RUN mkdir -p /var/www/tracston
COPY /home/tracston/website /var/www/tracston


# Start Apache
CMD [“/usr/sbin/httpd”,”-D”,”FOREGROUND”]

Build the Docker

docker build -t image_httpd .

Run the Docker

docker run -tid -p 8080:80 –name=container_httpd

change the value to 80:80 if you want to run as standard httpd


use your curl or your favorite browser to access the server to the specified port

Uploaded files:
If you have found my website, guides, articles or videos useful, please buy me a coffee