无法运行docker IIS windows容器



我是docker的新手,并试图在windows容器中运行遗留的。net应用程序(使用docker桌面)。这是我的dockerfile

FROM mcr.microsoft.com/windows/servercore:ltsc2019
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
RUN dism.exe /online /enable-feature /all /featurename:iis-webserver /NoRestart
#Configure IIS
RUN Import-Module WebAdministration;New-Item –Path IIS:AppPoolsCustomApppool
RUN C:windowssystem32inetsrvappcmd.exe set apppool /apppool.name:CustomApppool /processModel.identityType:SpecificUser /processModel.username:ususer1 /processModel.password:P@@Ss
RUN Install-WindowsFeature Web-Windows-Auth;
RUN Install-WindowsFeature Web-IP-Security;
RUN Install-WindowsFeature NET-WCF-HTTP-Activation45;
RUN Install-WindowsFeature Web-Dyn-Compression;
RUN Install-WindowsFeature Web-Scripting-Tools;
RUN Install-WindowsFeature Web-AppInit;
RUN Install-WindowsFeature Web-Http-Redirect;
RUN Install-WindowsFeature Web-WebSockets;
# Update permissions on website folder
RUN icacls 'c:inetpubwwwroot' /Grant 'IUSR:(OI)(CI)(RX)'
RUN icacls 'c:inetpubwwwroot' /Grant 'IIS AppPoolDefaultAppPool:(OI)(CI)(RX)'
RUN icacls 'c:inetpubwwwroot' /Grant 'IIS AppPoolCustomApppool:(OI)(CI)(RX)'
#Copy website files from App host folder to container wwwroot folder
COPY Admin/ "c:/inetpub/wwwroot/Admin"
COPY Sade/ "c:/inetpub/wwwroot/Sade"
COPY Rater/ "c:/inetpub/wwwroot/Rater"
#Copy Service Monitor file
COPY ServiceMonitor.exe C:/
RUN New-WebApplication -Name Admin -Site 'Default Web Site' -PhysicalPath C:inetpubwwwrootAdmin -ApplicationPool CustomApppool;
RUN New-WebApplication -Name Sade -Site 'Default Web Site' -PhysicalPath C:inetpubwwwrootSade -ApplicationPool CustomApppool;
RUN New-WebApplication -Name Rater -Site 'Default Web Site' -PhysicalPath C:inetpubwwwrootRater -ApplicationPool CustomApppool;
#Authentication Settings
# Enable Directory browsing
RUN C:Windowssystem32inetsrvappcmd.exe set config 'Default Web Site' /section:system.webServer/directoryBrowse /enabled:'True'
# Enable anonymous authentication
RUN Set-WebConfigurationProperty -Filter '/system.webServer/security/authentication/anonymousAuthentication' -Location 'Default Web Site' -Name enabled -Value True;
# Enable basic authentication
#RUN Set-WebConfigurationProperty -Filter '/system.webServer/security/authentication/basicAuthentication' -Location 'Default Web Site' -Name enabled -Value True;
# Enable Windows authentication
RUN Set-WebConfigurationProperty -Filter '/system.webServer/security/authentication/windowsAuthentication' -Location 'Default Web Site' -Name Enabled -Value False;
RUN Restart-Service W3SVC
EXPOSE 80
ENTRYPOINT ['C:ServiceMonitor.exe','w3svc']

我能够通过运行docker build -t demo/site来构建映像我正在运行这个命令来启动容器docker run -p 8000:80 demo/site:latest,但我得到这个错误:

At line:1 char:35
+ $ErrorActionPreference = 'Stop'; ['C:ServiceMonitor.exe','w3svc']
+                                   ~
Missing type name after '['.
At line:1 char:58
+ $ErrorActionPreference = 'Stop'; ['C:ServiceMonitor.exe','w3svc']
+                                                          ~
Missing argument in parameter list.
+ CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordEx
ception
+ FullyQualifiedErrorId : MissingTypename
请问,我错过了什么?我需要做些什么才能让容器启动,并能够在本地主机上浏览我的网站?

将最后一行的单引号替换为双引号。也可以尝试用CMD替换ENTRYPOINT。

最新更新