简体   繁体   中英

Unable to start .NET Windows Service in Docker container

I am new to Docker. I've a Windows Service created in .NET Framework. I can install and run the service on a Windows Server 2016 machine with the following commands.

1) SC CREATE "MyWindowsService" binpath= "C:\\MyWindowsService\\MyWindowsService.exe" start= auto DisplayName= "MyWindowsService" 2) SC START MyWindowsService

This is also the machine which has docker installed on it.

Following is my docker file:

FROM microsoft/dotnet-framework-build:4.7.1 
run mkdir c:\MyWindowsService

copy ./MyWindowsService/*.* /MyWindowsService/

CMD POWERSHELL Write-Host Folder created ; \
while ($true) { Start-Sleep -Seconds 3600 }

I am not trying to create or install the service from the docker file(That i'll do later). I am trying to run the SC command after the container is running in the interactive mode. The service installs successfully which i confirmed using the SC QUERY Command but the
SC START MyWindowsService gives an error : [SC] StartService FAILED 1053:

I've used other commands in the "it" mode like installutil.exe but didn't work.

There was a problem in the service code which caused it to stop. The service needed to connect to another server for which an entry in the host file of the container was required. Executed a powershell in the container to make that entry and the service is up an running since.

Thank you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM