简体   繁体   English

在 Docker 容器中安装 Windows 服务

[英]Install Windows service in Docker container

When I try to install an app as a service in my dockerfile I get an error that indicates that installutil.exe is showing the username dialog when installing the service.当我尝试在dockerfile应用程序作为服务安装时,我收到一条错误消息,表明installutil.exe在安装服务时显示用户名对话框。 Initially I wanted to use an account on the host's domain, but it seems Docker for Windows doesn't support the host network setting that is available on linux.最初我想使用主机域上的帐户,但 Windows 的 Docker 似乎不支持 linux 上可用的主机网络设置。

To get around this I am creating an admin user first and then calling installutil with the username and password parameters.为了解决这个问题,我首先创建了一个管理员用户,然后使用用户名和密码参数调用 installutil。 This gives the error这给出了错误

The account name is invalid or does not exist, or the password is invalid for the account name specified.帐户名无效或不存在,或指定帐户名的密码无效。

 FROM microsoft/dotnet-framework SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'Continue'; $verbosePreference='Continue';"] RUN New-LocalUser -Name "testuser" -Password (ConvertTo-SecureString -AsPlainText "Stackoverflow1234." -Force) -FullName "Test:User" -Description "LocalAdministrator" RUN Add-LocalGroupMember -Group administrators -Member adapteruser -Verbose RUN New-Item -Path "C./dev" -ItemType directory WORKDIR /dev COPY ":\dev" "C:\dev" RUN "C./Windows/Microsoft.NET/Framework64/v4.0.30319/InstallUtil.exe" /username=testuser /password=Stackoverflow1234 /LogToConsole=true /ShowCallStack myapp exe

I've also tried:我也试过:

 RUN net user /add testuser Stackoverflow1234 RUN net localgroup administrators testuser /add RUN net user

I have reviewed this similar question already: Dockerizing a Windows Service Docker for Windows我已经审查过这个类似的问题: Dockerizing a Windows Service Docker for Windows

To use the new user I had to add ".\" to the username (for local machine):要使用新用户,我必须在用户名中添加“.\”(对于本地机器):

 RUN "C:/Windows/Microsoft.NET/Framework64/v4.0.30319/InstallUtil.exe" /username=.\testuser /password=Stackoverflow1234. /LogToConsole=true /ShowCallStack myapp exe

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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