I am trying to dockerize one of our Projects running an Apache portal, which usually gets executed using the following command:
C:\Company\MiniServer\Apache2.4\bin\CompanyMiniServer.exe -k start -n CompanyMiniServer
Thus far, I managed to set up a Dockerfile that installs and runs this, but terminates the container immediately when run due to it not having an CMD. That Dockerfile looks like this:
# Starts from the windows server core FROM microsoft/windowsservercore # Install Visual C++ Redistributable for Visual Studio 2012 Update 4 x86 ADD http://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU3/vcredist_x86.exe C:/installers/vc2012/vcredist_x86.exe RUN C:\installers\vc2012\vcredist_x86.exe /quiet /install # Install Visual C++ Redistributable for Visual Studio 2015 Update 3 x86 ADD https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x86.exe C:/installers/vc2015/vc_redist.x86.exe RUN C:\installers\vc2015\vc_redist.x86.exe /quiet /install # Add the Files ADD Company C:/Company/ # Sets Shell Mode to use PowerShell SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] # Installs and starts the Company Mini Server via Powershell Script RUN C:\Company\InstallAndStartMiniServer.ps1
This works, but only when run using the following command, which I consider not to be a permanent solution, since I can’t use it in docker-compose:
docker run -p 6007:6007 -p 6008:6008 --name companyminiserver_container -d -it companyminiserver powershell
If I do it like this, I can then access the Mini Server via localhost:6007.
However, what I want is to make this work using the CMD command.
I have tried the following:
CMD [ "C:\\Company\\MiniServer\\Apache2.4\\bin\\CompanyMiniServer.exe" ]
This creates a persistent container when run even without the -it powershell suffix. However, it does not let me access the MiniServer as the previous solution, and instead displays the following error message, presumably because the “-k start -n CompanyMiniServer” parameters are missing:
Forbidden You don't have permission to access /portal/ on this server. Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
So I tried to add the parameters in a variety of ways, but neither of them were successful:
CMD [ "C:\\Company\\MiniServer\\Apache2.4\\bin\\CompanyMiniServer.exe","-k start","-n CompanyMiniServer" ] CMD [ "C:\\Company\\MiniServer\\Apache2.4\\bin\\CompanyMiniServer.exe","-k start -n CompanyMiniServer" ] CMD [ "C:\\Company\\MiniServer\\Apache2.4\\bin\\CompanyMiniServer.exe","-k","start","-n CompanyMiniServer" ] CMD [ "C:\\Company\\MiniServer\\Apache2.4\\bin\\CompanyMiniServer.exe","-k","start","-n","CompanyMiniServer" ] CMD [ "C:\\Company\\MiniServer\\Apache2.4\\bin\\CompanyMiniServer.exe -k start -n CompanyMiniServer" ]
All of these simply caused the container to auto-terminate again.
My main question is: How can I pass parameters to Apache in Docker for Windows (Windows Containers) using the CMD command in a Dockerfile? There probably is an easy way to do that, but I am still new to Docker, and thus still confused about many things, such as the proper use of CMD.
Can somebody please help me with this? Any feedback would be greatly appreciated.
Thanks in advance,