gpt4 book ai didi

docker - 无法启动容器。错误消息 : Open Compute System failed

转载 作者:行者123 更新时间:2023-12-02 21:30:25 25 4
gpt4 key购买 nike

我是容器新手,并创建了一个 Windows Docker 镜像,该镜像在本地运行良好,为 https://localhost 但是当我在 Docker Hub 上发布该镜像并尝试在 Web App Container 中使用时,它失败并显示错误消息: 无法启动容器。错误消息:打开计算系统失败。
这是我的 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;"

最佳答案

检查容器日志,但 Open Compute System Failed 可能表明检索和运行镜像时出现问题。加载图像和挂载后端存储存在超时。
您的 docker 文件做了很多不必要的工作。您的基本镜像是 cached image ,这很好,因为这意味着图像不会从新鲜中提取。但是 mcr.microsoft.com/dotnet/framework/aspnet:4.8 already具有 IIS、.NET 4.5(通过 .NET 4.8)和 IIS 可扩展性。您不需要公开 443,因为应用服务将在您的图像上绑定(bind)一个端口,以根据需要路由 HTTP 流量。您也不需要配置 SSL 证书,因为您将 configure that on the app service也是。
看看这个Dockerfile了解如何使用 .NETFX 应用程序配置图像,但我将从以下内容开始:
编辑:这是我完整的 dockerfile。

# 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/. ./

关于docker - 无法启动容器。错误消息 : Open Compute System failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64608281/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com