Create a Dockerfile
in your project
FROM httpd:2.4
COPY ./public-html/ /usr/local/apache2/htdocs/
Then, run the commands to build and run the Docker image:
$ docker build -t my-apache2 .
$ docker run -dit --name my-running-app -p 8080:80 my-apache2
Visit http://localhost:8080 and you will see It works!
Without a Dockerfile
If you don't want to include a Dockerfile
in your project, it is sufficient to do the following:
$ docker run -dit --name my-apache-app -p 8080:80 -v "$PWD":/usr/local/apache2/htdocs/ httpd:2.4
Configuration
To customize the configuration of the httpd server, just COPY
your custom configuration in as /usr/local/apache2/conf/httpd.conf
.
FROM httpd:2.4
COPY ./my-httpd.conf /usr/local/apache2/conf/httpd.conf