Hands-on guide for Apache HTTP Server using Docker
You can quickly get Apache up and running using the official Docker image.
docker run -d --name apache-server -p 8080:80 httpd:latest
# Note: Replace 8080 with the PORT works on your own machine.
index.html
:mkdir apache-content
echo "<h1>Hello from Apache in Docker!</h1>" > apache-content/index.html
docker run -d \
--name apache-custom \
-p 8081:80 \
-v $(pwd)/apache-content:/usr/local/apache2/htdocs/ \
httpd:latest
my-httpd.conf
):ServerName localhost
LoadModule mpm_event_module modules/mod_mpm_event.so
LoadModule dir_module modules/mod_dir.so
Listen 80
DocumentRoot "/usr/local/apache2/htdocs"
<Directory "/usr/local/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
DirectoryIndex index.html
docker run -d \
--name apache-with-conf \
-p 8082:80 \
-v $(pwd)/apache-content:/usr/local/apache2/htdocs/ \
-v $(pwd)/my-httpd.conf:/usr/local/apache2/conf/httpd.conf \
httpd:latest
docker rm -f apache-server apache-custom apache-with-conf