【问题标题】:Unable to start container. Error message: Open Compute System failed无法启动容器。错误消息:打开计算系统失败
【发布时间】: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


    【解决方案1】:

    检查容器日志,但 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,因为应用服务将在您的图像上绑定一个端口,以根据需要路由 HTTP 流量。您也不需要像 configure that on the app service 那样配置 SSL 证书。

    查看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/. ./
    

    【讨论】:

    • 谢谢,瑞恩...我会尝试更新你。另外,我可以使用这个图像 (mcr.microsoft.com/windows/servercore/iis) 代替 aspnet:4.8,因为它的大小几乎是一半。
    • 你可以使用任何你想要的图像。建议使用缓存的图像,因为提取这些图像不需要任何网络检索,根据图像大小,这可能会导致超时。
    • 我使用了您的 Dockerfile,它在本地再次正常工作,但在 Azure 上失败,并显示以下错误消息(包括上一条):01/11/2020 17:29:45.310 错误 - 站点:abc0111 -无法启动容器。错误消息:Docker API 响应状态码=InternalServerError, response={"message":"container 644b5135b4cb05e19cb959795e255b48d7bfeca47c1b5f3034b41a398cf06d44 在 hcsshim::System::Start: context 超过期限时遇到错误"}
    • @JSK 让我尝试回购。你的镜像是在 docker hub 还是 ASC 上?你的项目是 .NETFX asp.net 项目吗?如果是,是 Web 表单还是 MVC?
    • 这是一个公共 Docker 镜像,带有 sampleaspnet5 和一个 asp.net Web 表单项目。
    猜你喜欢
    • 2015-06-08
    • 2021-06-13
    • 1970-01-01
    • 2020-10-24
    • 2012-04-11
    • 2015-08-13
    • 2022-08-03
    • 2022-07-10
    • 2013-06-24
    相关资源
    最近更新 更多