我需要借助Dockerfile中的powershell启动Windows服务。但是我得到这样的错误:
Start-Service : Failed to start service 'MyWinService (MyWinService)'.
At line:1 char:1
+Start-Service -Name MyWinService
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError:(System.ServiceProcess.ServiceController:ServiceController) [Start-Service], ServiceCommandException
+ FullyQualifiedErrorId : StartServiceFailed,Microsoft.PowerShell.Commands .StartServiceCommand
我的Dockerfile就像:
FROM microsoft/iis:10.0.14393.206
COPY . .
SHELL ["powershell"]
RUN New-Service -Name "MyWinService" -BinaryPathName "c:\Common\MyWinService.exe"
RUN Start-Service -Name "MyWinService"
RUN Install-WindowsFeature NET-Framework-45-ASPNET ; \
Install-WindowsFeature Web-Asp-Net45
RUN Remove-WebSite -Name 'Default Web Site'
RUN New-Website -Name 'bchr' -Port 80 \
-PhysicalPath 'c:\bchr' -ApplicationPool '.NET v4.5'
EXPOSE 80
CMD Write-Host IIS Started... ; \
while ($true) { Start-Sleep -Seconds 3600 }