Home > Mobile >  Windows-Worker-Service stays in status starting until 1053 in docker-container
Windows-Worker-Service stays in status starting until 1053 in docker-container

Time:03-08

I have developed a Windows-worker service and I want to start it in a docker-based environment for automated testing. Therefore I built it with the following command:

dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true

Additionally I have the following Dockerfile:

 FROM mcr.microsoft.com/windows/servercore/insider:10.0.17763.107
 COPY ["Install/", "C:/Service/Name/"]
    
 RUN powershell New-Service -Name "Name" -BinaryPathName "C:\Service\Name\Name.exe"

When trying to start the service with Start-Service -Name "Name" the startup takes long and the service stays in the state Starting and then I get an 1053-error in the Eventlog (LogName=System).

Due to the fact, that the service did not start I made another one, that is mainly based on the template in Visual Studio, so it should only log a message to the eventlog. This service has the same behavior. When installing it on my local machine everything works fine.

Do you have any ideas why the service remains in the state Starting even though it does already the tasks of the Running-state?

CodePudding user response:

I solved the problem now, because I found the following issue: https://github.com/dotnet/runtime/issues/50020

UseWindowsService() does not work in Docker, so I had to specify WindowsServiceLifetime:

services.AddSingleton<IHostLifetime, WindowsServiceLifetime>();
  • Related