简体   繁体   English

无法运行 docker IIS windows 容器

[英]Unable to run docker IIS windows container

I am new to docker and trying to run legacy .NET applications inside a windows container (using docker desktop).我是 docker 新手,并试图在 windows 容器中运行旧的 .NET 应用程序(使用 docker 桌面)。 Here is my 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:\AppPools\CustomApppool
RUN C:\windows\system32\inetsrv\appcmd.exe set apppool /apppool.name:CustomApppool /processModel.identityType:SpecificUser /processModel.username:us\user1 /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:\inetpub\wwwroot' /Grant 'IUSR:(OI)(CI)(RX)'
RUN icacls 'c:\inetpub\wwwroot' /Grant 'IIS AppPool\DefaultAppPool:(OI)(CI)(RX)'
RUN icacls 'c:\inetpub\wwwroot' /Grant 'IIS AppPool\CustomApppool:(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:\inetpub\wwwroot\Admin -ApplicationPool CustomApppool;
RUN New-WebApplication -Name Sade -Site 'Default Web Site' -PhysicalPath C:\inetpub\wwwroot\Sade -ApplicationPool CustomApppool;
RUN New-WebApplication -Name Rater -Site 'Default Web Site' -PhysicalPath C:\inetpub\wwwroot\Rater -ApplicationPool CustomApppool;

#Authentication Settings
# Enable Directory browsing
RUN C:\Windows\system32\inetsrv\appcmd.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']

I am able to build the image by running docker build -t demo/site I am running this command to start the container docker run -p 8000:80 demo/site:latest but i am getting this error:我可以通过运行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

Please, what am i missing?请问,我错过了什么? What do i need to do to get the container to start, and to be able to browse my website on localhost?我需要做什么才能启动容器并能够在 localhost 上浏览我的网站?

Replace your single quotes on the last line with double quotes.用双引号替换最后一行的单引号。 Also try replacing ENTRYPOINT with CMD as well.也尝试用 CMD 替换 ENTRYPOINT。

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

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