다음을 통해 공유


Publish a Web App for Containers Windows Docker Image

I wrote these other articles here “How to add Docker support to your ASP.NET Core application” and here “Publish a Docker Windows image to Docker Hub using Visual Studio” that discussed how I got to this point.  So far, not many problems and it went pretty smooth.  When I added Docker support to my ASP.NET Core project it added a Docker file that identified the OS version I would be including with the application.  It included this by default:

 
FROM microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-1803 AS base
FROM microsoft/dotnet:2.1-sdk-nanoserver-1803 AS build

Then when I accessed the Azure portal I selected the Windows OS for the Web App for Containers blade and when I added the image it did not validate.  I received the following, Figure 1:

 
Cannot run this Operating System/Version in Windows Containers. Maximum supported OS version is 10.0.14393.

image

Figure 1, publish a windows OS image docker on web app for container azure app service

I looked around here and here for some images and through trial and error I found one that worked, Figure 2.

 
FROM microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-sac2016 AS base
FROM microsoft/dotnet:2.1-sdk-nanoserver-sac2016 AS build

image

Figure 2, publish a windows OS image docker on web app for container azure app service

Unfortunately, the container did not start and I received the following response, ASOD (Azure Screen Of Death)(*), when I accessed the site, Figure 3.

 
The Web App's container could not start
Please try again in few minutes
If you are an administrator of this Web App please verify your container settings and go to 
Azure Portal to review the diagnostic logs

image

Figure 3, publish a windows OS image docker on web app for container azure app service

To resolve that issue, I did what the message stated, I.e. enable and review the diagnostic logs.  Here is what I found in the D:\home\LogFiles\*_docker.log files via KUDU/SCM.

 
ERROR - Site: - Image pull reported error. Image: benperk/. failed to register layer: 
     re-exec error: exit status 1: output: remove \\?\C:\DockerData\windowsfilter\...cat: 
     The process cannot access the file because it is being used by another process.
ERROR - Site: - Pull image completed but it was not found locally. Image: benperk/
WARNING - Site: - Attempt 1 to start container was unsuccessful. Maximum attempts: 3. 
INFO - Site: - Purging after container failed to start
INFO - Site: - Purging pending logs after stopping container

I didn’t take any action other than to be patient, looking through the logs the process is downloading a large number of large files, so it can take some time to get everything loaded, installed and configured.  Ultimately, I read the following in the log files and the site was responding as expected.

 
INFO - Site: * - Creating container for image: benperk/*.
INFO - Site: * - Create container for image: benperk/* succeeded. Container Id 6396:::
INFO - Site: * - Start container succeeded. Container: 63962:::
INFO - Site: * - Waiting for container to be ready
INFO - Site: * - Container ready
INFO - Site: * - Configuring container
INFO - Site: * - Container ready
INFO - Site: * - Container start-up and configuration completed successfully

On a second publish to a different Windows Container for Web Apps I got this message in the D:\home\LogFiles\*_docker.log logs:

 
INFO - Site: * - Creating container image
ERROR - Site: * - Invalid Image type: IIS.
WARNING - Site: * - Attempt 1 to start container was unsuccessful. Maximum attempts: 3. 
INFO - Site: * - Purging after container failed to start

This happened because I am so used to selecting the publish menu item and publishing directly to a web app, I forgot that I need to pish the image to docker and then created the web app from the portal as seen in Figure 1 and 2 earlier in this article.  In noticed, see Figure 4 that the working one was considered a container while the broken one was not.

image

Figure 4, publish a windows OS image docker on web app for container azure app service

I deleted the broken app and deployed it correctly and all worked fine.

Some months ago I installed and configured a Nano server and wrote some posts about it.  Here they are.  I hadn’t seen much about Nano since I wrote them, it is nice to see it getting some traction.  I am especially interested in trying this one out “How to connect and configure IIS running on Nano”.  I see a link to Win-RM in the portal that will allow me to remote manage.