Installing msi on a docker container - .net

Need help with dockerizing legacy application
I have a legacy app which contains multiple components(msi installers). These components use variety of technologies like C#, windows forms, C++, MFC, .net remoting, C# webservices(asmx). Out of these components a couple of them are desktop ui applications.
I was researching the feasibility of dockerizing these components. I am aware that it is not possible to display UI from docker containers, but the UI components also have a command-line counterpart using which we can perform all the operations which can be done with UI.
I started with a simple component. This contains asmx web services developed in C# and is generally hosted on IIS on a windows machine.
It installs its files into the following locations
C:\program Files\ ==> configurable
I created the docker file with following actions
take a windows server core image and enable iis and other
Copy the installer from host machine to the container
Run the installer in silent mode using msiexec command.
When I run docker build command using this docker file, I am getting an error Could not access network location "C:\Program Files\\
No help from google.
Can anybody help me in getting around the issue.
I have a couple of questions
1. Does a docker container by default contain default windows directories like program files, program files(x86), user profile, Program data and app data?

I've done similar work 2 years ago, dockerizing some C# code we had in our organisation.
Here's a snippet from one of the Dockerfile that should help you achieve what you are trying to do -
FROM microsoft/windowsservercore
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
#Copy installers
RUN (New-Object System.Net.WebClient).DownloadFile('', 'c:\tools\MicrosoftAzureAuthoringTools-x64.msi') ;\
(New-Object System.Net.WebClient).DownloadFile('', 'c:\tools\MicrosoftAzureLibsForNet-x64.msi') ;\
Start-Process 'msiexec' -ArgumentList '/i c:\tools\MicrosoftAzureAuthoringTools-x64.msi /quiet /qn /norestart /log c:\tools\installAuth.log'; \
Start-Sleep -s 30 ;\
Start-Process 'msiexec' -ArgumentList '/i c:\tools\MicrosoftAzureLibsForNet-x64.msi /quiet /qn /norestart /log c:\tools\installLib.log';\
Start-Sleep -s 30 ;\
Remove-Item c:\tools\*.msi -force
My example downloads the files from the internet, then installs it from the c:\tools folder to which they were downloaded to, but it should work just as well and also eliminates dependency on files existing on the host machine.
Hope it helps.


Deploy .Net 4.5 WebApi project with WebDeploy using Docker

I am new to docker and trying to learn .Net 4.5 applications to go with Docker Windows Container on our on-premise data center.
I followed link [][1]
Following is my dockerfile for getting necessary docker images all is good:
FROM microsoft/windowsservercore
RUN dism /online /enable-feature /all /featurename:iis-webserver /NoRestart
FROM windowsserveriis
RUN dism /online /enable-feature /all /featurename:IIS-ASPNET45
FROM windowsserveriisaspnet
RUN mkdir c:\install
ADD WebDeploy_2_10_amd64_en-US.msi /install/WebDeploy_2_10_amd64_en-US.msi
WORKDIR /install
RUN powershell start-Process msiexec.exe -ArgumentList '/i
c:\install\WebDeploy_2_10_amd64_en-US.msi /qn' -Wait
Now the Problem: I use web deploy to create zipped folder, paramerter files and windows script command and then use ANOTHER DOCKER file to deploy my webapi and it is as follows:
FROM windowsserveriisaspnetwebdeploy
RUN mkdir c:\webapplication
WORKDIR /webapplication
ADD /Default\Web\Site/
ADD InventoryService.deploy.cmd Default\Web\Site/InventoryService.deploy.cmd
ADD InventoryService.SetParameters.xml
RUN InventoryService.deploy.cmd, /Y
and it fails with "InventoryService.deploy.cmd" is not recognized as an internal or external command, operable program or batch file.
I spent a lot of hours googling and stackoverflowing but to no avail. Can you please throw some light on
How we will deploy webapi with .net 4.5" using container?
what I am doing wrong in above dockerfile?
I will like to deploy this webapi to use given port (i.e. 12345 and not 80), so how will we have to do it?
Your help will be really appreciated!!

How to install Tomcat in Docker Windows Server Container?

On my windows server 2016 tp5 virtual machine, I would like to create a simple native windows based docker example without virtualbox.
The example needs tomcat for windows and since this windows server 2016 docker container uses a shared windows kernel, installing tomcat should be straight forward, alas! Using the following powershell docker build command stops with non-zero code: 255
Dockerfile in c:\build:
FROM microsoft/windowsservercore
RUN powershell -Command wget -Uri -OutFile "$env:TEMP\"
docker build c:\build
---> Running in 317a3572890e
The command 'cmd /S /C powershell -Command wget -Uri -OutFile "$env:TEMP\"' returned a non-zero code: 255
Although the zip file has been downloaded in my users temp dir.
Can anybody tell me, how a native windows tomcat installation should look like, as I am not really deep in this stuff.
As mentioned here:
The error code "255" usually means that it is not able to find the file you are asking it to execute
So try and test with the full path and name of the binary(ies) involved in your RUN command line (like powershell)
But test also a simpler case:
RUN dir c:\Users\
This has been recently reported as failing with the same exit code 255, which would mean the latest docker on Windows Server 2016 Technical Preview 5 has a bug.

How to execute a PostGre exe file with silent mode?

I would install PostGreSQL 9.1 on a Windows Server 2012.
I want to used a PowerShell script.
With my JDK executables file, I use Start-Process "Myfile" -ArgumentList "/s" -Wait
But the argument \s don't work with my PostGre executables file.
Have you an idea ?
You can use Install-Postgres Powershell module, it's on TechNet Gallery.
The Install-PostgreSQL PowerShell module does the following:
creates a local windows user that PostgreSQL will use
downloads the PostgreSQL installer provided by EnterpriseDB
installs Postgres unattended using the supplied parameters
sets postgres windows user as owner of Postgres files and folders
sets Postgres windows service to run under postgres local user
creates pgpass.conf file in AppData
copies configuration files to data directory
opens the supplied port that PostgreSQL will use in the Windows
Import-Module Install-Postgres
Install-Postgres -User "postgres" -Password "ChangeMe!"
I have used this command : Start-Process $installFile -ArgumentList "--unattendedmodeui minimal --mode unattended --prefix $dest --datadir $dest\data --servicepassword $pwd" -Wait
Thanks for your help ! :)

Batch script not doing anything when execute from remote machine using ssh

i'm having a problem while executing batch script from linux machine.
I've a windows machine installed server2008, I need to automate some windows task that executes from linux machine. I've installed cygwin software on windows VM and create a batch script that is running fine from cygwin terminal. i.e cd ~/;./script.bat
When I execute the same script from linux machine using ssh it seems works fine and print script executed successfully but when I checked that the task from windows it did nothing.
cat script.bat
#echo off
set sourcePasswd=%1
set destinationPasswd=%2
set destinationProjectName=%3
set user=%4
set xmlPath=C:\cygwin\home\%user%\Duplicate.xml
ECHO Start : Duplication project source for %destinationProjectName%
"C:\Program Files (x86)\Common Files\MySoftware\Duplicate.EXE" -f %xmlPath% -sp %sourcePasswd% -dp %destinationPasswd% -sup -md -dn %destinationProjectName%
ECHO Finish : Duplication project source for %destinationProjectName%
Looks like Leopard hasn't been back since he posted the question or the link to the answer, so I'll be the Point Pimpette tonight and fill in the blank.
The answer below is from the link:
It was fixed after doing the following setup :
Open control panel=> Administrative Tools=>Computer
lookup the sshd service, right
click=>properties=>log on, and check the checkbox for Allow service
to interact with desktop
restart the service.

Add nginx.exe as Windows system service (like Apache)?

I set up NGINX as a front end server for static content and I use Apache as a back-end server for other thing.
The thing is I can't find a logical answer that allows me to make nginx.exe a Windows system service (like my Apache).
Any come across an answer to this?
How to do it with Windows Service Wrapper
(Note: There are promising alternatives by now - see also NSSM solution described in answer below from Adamy.)
Download the latest version of Windows Service Wrapper via github or nuget.
Current version as of this writing is v2.2.0
Since v2.x executables for .NET2.0 and .NET4.0 are available - others only on demand.
Rename winsw-*.exe to something like nginxservice.exe.
This is the name that will show up for the process that owns your nginx process.
Place an XML file next to the exe with the same base name, e.g. nginxservice.xml. The contents should be like below (verify your nginx location).
You can find up to date details about the configuration on the config github page, a generic example showing all possible options here and an installation guide.
Run the command nginxservice.exe install as administrator.
You will now have an nginx service in your Services! (It is set to start automatically on boot; if you want to start your server, you must manually start the service (net start nginx).)
Detailed description of correctly setting up nginx as a Windows Service:
Additional info not contained in above blog post:
You can find the latest version of the Windows Service Wrapper also via this Maven Repository:
Examples for Maven + Gradle:
compile "com.sun.winsw:winsw:2.2.0"
repositories {
maven { url }
Download NSSM form .
"Run %NSSM_HOME%\nssm.exe install “Nginx”"
Select the Nginx executable in the NSSM dialog, then OK.
Go to Services and start the new created service "Nginx", done.
SC.EXE will only work for executables that already support the Windows Services API and can respond properly to start and stop requests from the Services Control Manager (SCM). Other regular applications, not specifically written as a service, will simply fail to start (usually with error 1053)...
For those exe's, you need a "service wrapper" -- a small utility that can accept the start/stop commands from the SCM and run/terminate your application accordingly. Microsoft provides Srvany (which is free yet very basic), but there are several other free and commercial alternatives.
BTW, you should check out this guide showing how to run Nginix as a service, especially step 7 which discusses how to stop Nginix properly. Not every wrapper will support that functionality (Srvany doesn't)...
You can using start.bat and stop.bat to realize the same effect.
REM Start Nginx
tasklist /FI "IMAGENAME eq nginx.exe" 2>NUL | find /I /N "nginx.exe">NUL
REM Nginx is NOT running, so start it
cd \nginx
start nginx.exe
ECHO Nginx started.
) else (
ECHO Nginx is already running.
REM Stop Nginx
tasklist /FI "IMAGENAME eq nginx.exe" 2>NUL | find /I /N "nginx.exe">NUL
IF "%ERRORLEVEL%"=="0" (
REM Nginx is currently running, so quit it
cd \nginx
nginx.exe -s quit
ECHO Nginx quit issued.
) else (
ECHO Nginx is not currently running.
The easiest way I've found, was using the Chocolatey package manager.
Once Chocolatey is installed, you open an administrative prompt and type:
choco install nginx
You now have a Windows service named 'nginx' running.
Download zip file from here.
Extract nginx-service.exe from winginx\build and run it.
Official nginx wiki referes on winginx for this purpose. It builds exe-installer in linux environment.
Process looks like this:
sudo apt-get install nsis make
cd winginx-master/
ls -lh ./build/nginx-service.exe
To get actual versions you should specify them in Makefile.
NSSM is the best tool to run Nginx as a service.
If you do not want to use any external 3rd party software then you can implement any of these two methods.
Windows Task Scheduler
Windows startup shortcut
Windows Task Scheduler
As mentioned in this answer prepare one start.bat file.
Put this file where nginx.exe is present.
Open windows task scheduler and set up the task as described in this answer to run it indefinitely.
Do not forget to run this task as the highest privilege with the system account, more details can be found here.
Make the task to start daily at a certain time, through the bat file it will check whether the service is already running to avoid creating multiple nginx.exe instances.
If due to some reason Nginx shuts down, within 5 minutes it will start.
Windows Startup shortcut
Create one shortcut of nginx.exe and put it in the startup folder of Windows.
Follow this answer to find your startup location.
Nginx will run automatically whenever you log in to the system.
This one is the easiest. However, it is dependent on user profile i.e. if you are running Nginx on a server, it will run only for your user account, when you log off it stops.
This is ideal for dev environment.
Rather than turning nginx into a service, or using CMD to start a process, which really doesn't seem to work. I found that Powershell makes it easy to startup nginx as a detached process. I've combined starting nginx with PHP. Below is the script, named "start-nginx.ps1"
$fcgiPort = ""
$PHPini = "c:\php\php.ini"
$ErrorActionPreference = "SilentlyContinue"
function restart {
Push-Location /nginx
Stop-Process -Force -Name nginx
Start-Process ./nginx.exe -WindowStyle Hidden
Stop-Process -Force -Name php-cgi
Start-Process "c:\php\php-cgi.exe" -ArgumentList ("-b" + $fcgiPort + " -c " + $PHPini) -WindowStyle Hidden
This script can be executed from any directory, but needs to be customized for where your nginx installation is located.
This script includes a silent attempt to kill nginx and PHP before launching both.
Windows systems are supposed to recognize ".ps1" files as powershell, even in the CMD prompt.
I created another small script to kill the running processes, which simply removes the "start-process" lines from this file.
To run at startup, I used the win-R command to navigate to the directory shell:startup
Placing a shortcut to the startup script in this directory, nginx starts at boot!
Powershell also includes a much more sophisticated ability to schedule tasks, and it is possible to schedule this script to run at startup. See This Link
From the article:
$trigger = New-JobTrigger -AtStartup -RandomDelay 00:00:30
Register-ScheduledJob -Trigger $trigger -FilePath $HOME/start-nginx.ps1 -Name startNginx
Combined, I think this approach gets you everything you'd need from an nginx windows service and doesn't require any third-party applications.