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

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

Problem

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.

Solution

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 https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \
&& rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

# 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

EXPOSE 80

# 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

Test

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