Search code examples
dockerdockerfileazure-web-app-servicecontainersdocker-for-windows

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


I am new to the containers and have created a Windows Docker image which is running fine locally as https://localhost but when I published the image on Docker Hub and tried to use in Web App Container its failing with the error message: Unable to start container. Error message: Open Compute System failed.

This is my 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;"

Solution

  • Check the container logs but an Open Compute System Failed is could indicate a problem retrieving and running your image. There is a timeout for loading the image and mounting the backend storage.

    Your docker file is doing a lot that's unnecessary though. Your base image is a 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 as well.

    Have a look at this Dockerfile for how you can configure your image with your .NETFX application but I would start with the following:

    EDIT: Here's my complete 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/. ./