Kan*_*kan 8 windows-services docker docker-for-windows
我正在研究应用程序可能的 dockerisation。该应用程序包括多个 Windows 服务 (.NET WCF)。我还没有尝试为 Windows 服务创建一个 dockerfile。但是,如果有人可以向我提供一些指示是否有效,我将不胜感激。
QA *_*ive 11
在您的情况下,我可能会为每个 Windows 服务创建一个映像。
以下 Dockerfile 非常适合我将 Windows 服务构建到 docker 映像中。
您的所有服务文件都需要位于 docker 上下文的“Installs”文件夹中,以及一份 InstallUtils.exe 文件(来自 .NET / Visual Studio)。
# escape=\
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.7.2-windowsservercore-1709
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
COPY ["Installs/", "/Service/"]
WORKDIR "C:/Service/"
RUN "C:/Service/InstallUtil.exe" /LogToConsole=true /ShowCallStack SmartFormsToWorkInjuryReportingService.exe; \
Set-Service -Name "\"My Windows Service Name\"" -StartupType Automatic; \
Set-ItemProperty "\"Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\My Windows Service Name\"" -Name AllowRemoteConnection -Value 1
ENTRYPOINT ["powershell"]
CMD Start-Service \""My Windows Service Name\""; \
Get-EventLog -LogName System -After (Get-Date).AddHours(-1) | Format-List ;\
$idx = (get-eventlog -LogName System -Newest 1).Index; \
while ($true) \
{; \
start-sleep -Seconds 1; \
$idx2 = (Get-EventLog -LogName System -newest 1).index; \
get-eventlog -logname system -newest ($idx2 - $idx) | sort index | Format-List; \
$idx = $idx2; \
}
Run Code Online (Sandbox Code Playgroud)
仅供参考,您可以通过以下方式运行该服务:
docker run --rm --net=MyNet --platform=windows -p 80:80 --name MyWindowsServiceContainer mywindowsserviceimage
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7670 次 |
| 最近记录: |