【发布时间】:2020-10-30 12:21:46
【问题描述】:
我是容器新手,并创建了一个 Windows Docker 映像,该映像在本地运行良好,https://localhost 但是当我在 Docker Hub 上发布该映像并尝试在 Web App 中使用时容器失败并显示错误消息:无法启动容器。错误信息:打开计算系统失败。
这是我的 Dockerfile
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019
ARG source
WORKDIR /inetpub/wwwroot
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
RUN Install-WindowsFeature NET-Framework-45-ASPNET ; "\
Install-WindowsFeature Web-Asp-Net45; \
Invoke-WebRequest -UseBasicParsing -Uri "https://dotnetbinaries.blob.core.windows.net/servicemonitor/2.0.1.6/ServiceMonitor.exe" -OutFile "C:\ServiceMonitor.exe"
#Expose port 443 to allow incoming traffic over the default HTTPS port
EXPOSE 443
#create a folder on the container to hold the code
RUN powershell -Command \
New-Item -Path sampleaspnet -ItemType Directory
#Set the newly created folder in docker as the working directory for subsequent commands
WORKDIR 'C:\inetpub\wwwroot\sampleaspnet'
#Copy everything from where you are on host to the working directory in docker (this folder should contain your SSL cert)
COPY ./bin/Release/PublishOutput/ .
COPY IIS_Docker.pfx .
RUN powershell.exe -Command "\
Import-Module IISAdministration; \
Import-Module WebAdministration; \
Remove-Website -Name 'Default Web Site'; \
New-Website -Name 'sampleaspnet' -IPAddress '*' -Port 443 -PhysicalPath 'C:\inetpub\wwwroot\sampleaspnet' -ApplicationPool '.NET v4.5' -Ssl -SslFlags 0; \
#If you have a password on your SSL Cert, put it here as it needs "secured". If not, remove this line and the argument below it; \
$pwd = ConvertTo-SecureString -String 'admin123456' -Force -AsPlainText; \
#Import the certificate and store it in a variable to bind to later; \
$cert = Import-PfxCertificate -Exportable -FilePath 'IIS_Docker.pfx' -CertStoreLocation cert:\localMachine\My -Password $pwd; \
#Take the imported certificate and bind it to all traffic toward port 443 (you need to specify IP if you want multiple apps on 1 docker which I believe is ill-advised); \
New-Item -Path IIS:\SslBindings\0.0.0.0!443 -value $cert;"
【问题讨论】:
标签: docker dockerfile azure-web-app-service containers docker-for-windows