dockerfiles-windows icon indicating copy to clipboard operation
dockerfiles-windows copied to clipboard

My windows service in the image can't auto start when I start the container

Open dat-trinhtien opened this issue 5 years ago • 0 comments

Hello guys, Please help me, I have built an image windows server core with a windows service inside. I have set (-StartupType Automatic) to that service, but when the container is online, the service doesn't start. Here is the command in Dockerfile

New-Service -Name $service_name -DisplayName $service_display_name -Description 'Domain Handlers' -BinaryPathName $service_path -StartupType Automatic

and here is the status of that service I got from the running container.

ExitCode  : 0
Name      : Project-Dev
ProcessId : 0
StartMode : Auto
State     : Stopped
Status    : OK

I also have two solutions for now. First, I think I can make a script and set it runs in ENDTRYPOINT or CMD, that script will start the service when the container is online. Second, I saw that the service is running under localsystem permission and have heard about LocalService and NetworkService, so the question is if my service runs under Localservice or networkservice, then It can auto start? (I thought about the permission, maybe the service can't start because of the permission) So, please help me to get out of these stuffs

dat-trinhtien avatar Feb 25 '20 09:02 dat-trinhtien