无法启动容器。错误消息:打开计算系统失败

Unable to start container. Error message: Open Compute System failed

我是容器的新手,我创建了一个 Windows Docker 图像,在本地 运行 很好 https://localhost 但是当我在 Docker Hub 上发布图像并尝试在 Web App Container 中使用它时失败并显示错误消息:无法启动容器。错误消息:打开计算系统失败。

这是我的Docker文件

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[=10=].0.0.0!443 -value $cert;"

检查容器日志,但 Open Compute System Failed 可能表示检索和 运行 您的图像出现问题。加载镜像和挂载后端存储超时。

您的 docker 文件做了很多不必要的事情。您的基本图像也是 cached image, which is good because that means images aren't being pulled from fresh. But mcr.microsoft.com/dotnet/framework/aspnet:4.8 already has IIS, .NET 4.5 (through .NET 4.8), and IIS extensibility. You don't need to expose 443 because the app service will bind a port on your image to route HTTP traffic as necessary. You also don't need to configure a SSL certificate as you'll configure that on the app service

查看此 Dockerfile 以了解如何使用 .NETFX 应用程序配置图像,但我将从以下内容开始:

编辑:这是我的完整 docker 文件。

# image for building our app
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8 AS build
WORKDIR /app

# copy the project files
COPY *.sln .
COPY DemoForms.Web/*.csproj ./DemoForms.Web/
COPY DemoForms.Web/*.config ./DemoForms.Web/
RUN nuget restore

# build it
COPY DemoForms.Web/. ./DemoForms.Web/
WORKDIR /app/DemoForms.Web
RUN msbuild /p:Configuration=Debug

# and run it
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019 as runtime
WORKDIR /inetpub/wwwroot
COPY --from=build /app/DemoForms.Web/. ./