3

I want to create a Docker Image that can be hosted on Azure App Services for Windows. My application is based on ASP.NET Core 2.1 and according to the official list of .NET images images, I should be able to simply use microsoft/dotnet:2.1-aspnetcore-runtime.

I can build the Dockerfile on a Windows machine successfully and was able to run it there without issues. But after uploading it to Docker Hub and setting it as the App Service's Docker Image, I get the following error message:

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

According to the Azure App Services Documentation, it should support the microsoft/dotnet:2.1-aspnetcore-runtime as one of the pre-installed parent images.

When inspecting my Docker Image, I found, that the used image seems to be too new for Azure App Services:

"Architecture": "amd64",
"Os": "windows",
"OsVersion": "10.0.17134.285" <-- too new

After some research, I found in this blog post, that Azure App Services on Windows might only accept microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-sac2016 image. So I tried to rebuild the Docker Image with these.

This time, the App Service accepted the image, but was unable to start it, throwing the following logs:

02/10/2018 14:15:09.437 ERROR - Site: rothiewindockerdemo - Image pull reported error. Image: robinmanuelthiel/contosomaintenance-api:latest-windows-sac2016. failed to register layer: re-exec error: exit status 1: output: remove \\?\C:\DockerData\windowsfilter\93b716197958ceb58006ff3d978fcb3202f7866d00d6d8d69513cf0478a17a7f\UtilityVM\Files\Windows\servicing\Packages\Microsoft-UtilityVM-Core-Package~31bf3856ad364e35~amd64~~10.0.14393.0.cat: The process cannot access the file because it is being used by another process.
02/10/2018 14:15:09.437 INFO - Site: rothiewindockerdemo - Image: robinmanuelthiel/contosomaintenance-api:latest-windows-sac2016
Custom Registry: https://index.docker.io

02/10/2018 14:15:09.439 ERROR - Site: rothiewindockerdemo - Pull image completed but it was not found locally. Image: robinmanuelthiel/contosomaintenance-api:latest-windows-sac2016
02/10/2018 14:15:09.441 WARNING - Site: rothiewindockerdemo - Attempt 1 to start container was unsuccessful. Maximum attempts: 3. 
02/10/2018 14:15:09.568 INFO - Site: rothiewindockerdemo - Purging after container failed to start
02/10/2018 14:15:09.582 INFO - Site: rothiewindockerdemo - Purging pending logs after stopping container

So what is the correct Windows Docker Base Image for ASP.NET Core 2.1 Docker Containers on Azure App Services?

That's my Dockerfile:

#######################################################
# Step 1: Build the application in a container        #
#######################################################

# Download the official ASP.NET Core SDK image 
# to build the project while creating the docker image
FROM microsoft/dotnet:2.1-sdk as build
WORKDIR /app

# Restore NuGet packages
COPY *.csproj .
RUN dotnet restore

# Copy the rest of the files over
COPY . .

# Build the application
RUN dotnet publish --output /out/ --configuration Release

#######################################################
# Step 2: Run the build outcome in a container        #
#######################################################

# Download the official ASP.NET Core Runtime image
# to run the compiled application
FROM microsoft/dotnet:2.1-aspnetcore-runtime

WORKDIR /app

# Open HTTP and HTTPS ports
EXPOSE 80
EXPOSE 443

# Copy the build output from the SDK image
COPY --from=build /out .

# Start the application
ENTRYPOINT ["dotnet", "MyApp.dll"]
Robin-Manuel Thiel
  • 2,206
  • 19
  • 26

3 Answers3

6

The issue lies in the fact that microsoft/dotnet:2.1-aspnetcore-runtime is a multi-architecture base image. This means that Docker build will pick the best architecture for your local machine (the machine where you are building your docker image). I assume that your local machine is Windows 10 April 2018 Update (Version 1803 - Whose build number 17134.407). As of now, we only support images based off of Windows Server 2016 (Version 1709, up to build number 14393.XX).

In order to “force” a specific version, please use this base image instead: microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-sac2016. You can check all the available tags in https://hub.docker.com/r/microsoft/dotnet/

We will work on calling this out specifically in our documentation.

Robin-Manuel Thiel
  • 2,206
  • 19
  • 26
Vini Soto
  • 376
  • 1
  • 5
1

Is important to mention that Windows Containers on App Service is currently in Preview.

The validation on the portal "Cannot run this Operating System/Version in Windows Containers. Maximum supported OS version is 10.0.14393.9999." is shown because we are running the servers with Windows Server 2016 RS1 and currently can't run containers for RS3+. We are currently working on enabling them, but we don't have an ETA to share at this point.

If the validation passes, it means that the specified image should work fine and the issue you are seeing is not directly related to the image. It is a bug in the platform and it seems similar to the issue reported here: https://github.com/Microsoft/hcsshim/issues/155

We will continue investigating and thanks for reporting the issue

Joaquín Vano
  • 414
  • 1
  • 3
  • 5
  • As you can see above, it is a pretty basic ASP.NET Core image with nothing fancy. It even happens with a newly created App Service. Is there any way, how I can further investigate this? How should I proceed? – Robin-Manuel Thiel Oct 03 '18 at 21:27
  • We looked at the issue and we have mitigated the problem. Your container is now running: http://rothiewindockerdemo.azurewebsites.net – Joaquín Vano Oct 04 '18 at 01:27
  • We are working on a permanent fix but the issue seems to repro with nanoserver images. I recommend to try servercore images while we fix the issue – Joaquín Vano Oct 04 '18 at 01:40
  • Hi @joaquín vano, thanks for looking into this. Glad to see that my image is running now on your App Service. Can you tell me, what you did to get it working? How can I run it on mine? – Robin-Manuel Thiel Oct 10 '18 at 10:20
  • The workaround is to stop all containers from the host and start them again. However, we run a small container called canary which handles synthetic traffic as part of our health monitoring and unfortunately, the users can't stop it since is part of the system. We will be deploying a fix by the end of October to alleviate the issue. Sorry for the inconvenience. – Joaquín Vano Oct 11 '18 at 21:41
  • Alright, thanks for the clarification. So I have to wait until end of October. To answer my inital question: Is my Dockerfile correct or what would be the correct base image then? `microsoft/dotnet:2.1-aspnetcore-runtime` or `microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-sac2016`? – Robin-Manuel Thiel Oct 12 '18 at 08:01
0

The answer above that was marked as an answer is not correct. It leads you to believe that using microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-sac2016 will solve your problems, but it won't. I tested this on Azure Container instances, and it does not work.

The solutions is this: when you get OsVersionNotSupported it means that the image was create with windows version that is not supported, and Microsoft currently does not support any SAC versions (SAC is Semi-Annual Channel). So versions like 1709 and 1803 will NOT WORK. Also the "solution" above is not going to work, since it uses that tag of SAC2016.

For all tags that you can use in docker file, go here: https://github.com/dotnet/dotnet-docker/blob/master/TAGS.md

You need to go to https://learn.microsoft.com/en-us/azure/container-instances/container-instances-troubleshooting and read the section "OS version of image not supported". It clearly states that you need to "...always deploy Windows Server 2016 (LTSC)-based images...".

user1405583
  • 121
  • 2
  • 10
  • The question was NOT about Azure Container Instances, but about Azure App Services for Windows Containers. For them, the as correct marked answer works fine. – Robin-Manuel Thiel Jan 24 '19 at 15:49
  • 1
    I too have just wasted a lot of time trying to rebuild my containers off the 1709 base images only to find that they're not supported in Azure Container Instances. Appreciate the original question may not have been specifically for Azure Container Instances, but that wasn't clear. The link to github above is broken so I still don't actually know what base image to use :( – Ross Ellerington Mar 13 '19 at 16:40