Installing Apache Web Server through Docker File For Windows Container
In this blog, we will show you Installing Apache Web Server through Docker File For Windows Container on windows 2016 container host.
REQUIREMENTS
- Windows container host with docker service installed
- Base windows server core image
- Apache web server installation file
DOWNLOAD APACHE WEB SERVER
- Go to the URL https://archive.apache.org/dist/httpd/binaries/win32/ from your web-browser.
- Download the latest modified apache web server setup file.
PREPARING FOR APACHE INSTALLATION
- Create a new folder named apache on c:\ drive on windows container host machine using below command.
New-Item -ItemType Directory -Path c: -name apache
- create a new folder named setup under apache on c:\drive using below command.
New-Item -Type Directory -Path C:\apache\ -Name setup
- Copy the downloaded apache setup file to c:\apache\setup folder.
CREATING DOCKER FILE
- Create a file named dockerfile on c:\apache folder using below command.
New-Item -Type file -Path c:\apache -name dockerfile
- Add the below coding in the dockerfile and save it.
“#THIS DOCKER FILE IS DEVELOPED BY ASSISTANZ NETWORKS
#SPECIFY THE CONTAINER IMAGE
FROM microsoft/windowsservercore
#COPY THE APACHE INSTALLATION FILES INTO THE CONTAINER
ADD ./setup c:/apache
#INSTALLING APACHE
RUN [“msiexec.exe”, “/i”, “C:\\apache\\apache_2.2.8-win32-x86-no_ssl.msi”, “/qn”]
#APACHE CONFIGURATION
RUN powershell.exe -command \
#COPY CUSTOMIZE HTTPD CONFIGURTION FILE TO APACHE conf FOLDER
copy-item c:/apache/httpd.conf -destination ‘”c:/program files (x86)/Apache Software Foundation/Apache2.2/conf”‘; \
#INSTALLING APACHE SERVICE USING BATCH FILE
cmd.exe /c c:/apache/service.bat; \
#SET APACHE SERVICE TO RUN UNDER LOCAL SYSTEM ACCOUNT
sc.exe config apache2.2 obj=LocalSystem; \
#REMOVE THE APACHE SETUP FILES DIRECTORY
remove-item c:/apache -Recurse
- You can download this docker file from the GitHub URL https://github.com/assistanz247/APACHE/blob/master/dockerfile
- We have created customized httpd.conf file for this installation. You can download this .conf file from the GitHub URL https://github.com/assistanz247/APACHE/blob/master/httpd.conf
- We create a simple batch file to register the apache service and its available in GitHub URL https://github.com/assistanz247/APACHE/blob/master/service.bat
- Copy these two files httpd.conf & service.bat in c:\apache\setup folder.
- Now everything is set to start the installation.
INSTALLING APACHE ON WINDOWS CONTAINER
- Open PowerShell window and execute the below command to build the apache container image using docker file.
docker build -t apache c:\apache
- It will take few minutes to complete the building process.
VERIFY THE BUILT IMAGE
- From the PowerShell window, type docker images command to verify the available images in the container host.
- Run the below command to launch a container using the built image.
docker run -it -p 80:80 apache powershell
- Once the container is online, we can verify the apache service status.
- Access the container using the container host IP from outside VM.
Note: In this demo, our container host IP is 192.168.232.80
- Also, we can able to access the apache web page using the container IP from the container host.
VIDEO
Thanks for reading this blog. We hope it was useful for you to learn how to install apache on windows container.
Loges