I am trying to run a app build on dotnet Core 3.0, packed in a docker image, on a production server running OS w2016.
When I run the docker image at the server I got this incompatible image error:
a Windows version 10.0.17763-based image is incompatible with a 10.0.14393 host
As I understand, I need to build the image using a base image compatible with the target host. So, I need to look for 1607 base images . The problem is, I can't find an image for dotnet Core 3.0 targeting that server version.
W2016 is recent, docker should allow to run in every server, so what i am missing here?
For clarity, here the dockerfile i am trying to write:
#this image not exists for os version 1607
FROM mcr.microsoft.com/dotnet/core/runtime:3.0-nanoserver-1607 AS base
WORKDIR /app
#this image not exists for os version 1607
FROM mcr.microsoft.com/dotnet/core/sdk:3.0-nanoserver-1607 AS build
WORKDIR /src
COPY ["ConsoleApp7/ConsoleApp7.csproj", "ConsoleApp7/"]
RUN dotnet restore "ConsoleApp7/ConsoleApp7.csproj"
COPY . .
WORKDIR "/src/ConsoleApp7"
RUN dotnet build "ConsoleApp7.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "ConsoleApp7.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "ConsoleApp7.dll"]
Update:
This is my first docker project, so i probably lack some knowledge. According to this post dotnet core image is not supported on w2016.
But should i be able to run using hiper-v isolation? Following this official post, i try to run
I try this command:
docker run -it --isolation=hyperv mcr.microsoft.com/windows/servercore:ltsc2019 cmd
but it fails with the following error because still wants a compatible image:
no matching manifest for windows/amd64 10.0.14393 in the manifest list entries.
Update2:
For clarity, the error:
a Windows version 10.0.17763-based image is incompatible with a 10.0.14393 host
was throw when running an image based on mcr.microsoft.com/dotnet/core/runtime:3.0-nanoserver-1903 for my pathfinder app.
The problem is how to pack the app and run on a windows 2016 server
According to the error messsage a Windows version 10.0.17763-based image is incompatible with a 10.0.14393 host
, you're running Windows, version 1607 as your Docker host. You haven't provided which tag you were referencing when you got this error so I'm going to assume it was a manifest tag like 3.0
. In that case, Docker will attempt to resolve that manifest tag to a concrete tag that is compatible with the Docker host. Since there is no published tag for 3.0 on Windows 1607, you'll get this error.
Attempting to make this happen by referencing different tags or through Docker command settings won't help you. You cannot use an older version of Windows to build a Docker image of a newer Windows version. That's true regardless of what isolation setting you're using. You'll need to upgrade your Docker host machine to a currently supported version of Windows. Currently supported Windows versions of .NET Core runtime images can be found here: https://hub.docker.com/_/microsoft-dotnet-core-runtime.
You can also read more about Windows container version compatibility here: https://learn.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility
Another option is to define your own Dockerfile that installs .NET Core. That way you can define the exact Windows base image that you want to use. This is useful when the official images do not provide the Windows version you require. Since there is no 1607-based version of Nano Server available anymore due to end of support, you'd need to use Server Core. In that case, you'd use mcr.microsoft.com/windows/servercore:1607
as your base image and install .NET Core on top of that. Detailed instructions for how to install .NET Core in a Dockerfile can be found here: https://github.com/dotnet/dotnet-docker/blob/master/samples/snippets/installing-dotnet.md. An example of this would be:
# escape=`
FROM mcr.microsoft.com/windows/servercore:1607
RUN powershell -Command `
$ErrorActionPreference = 'Stop'; `
$ProgressPreference = 'SilentlyContinue'; `
Invoke-WebRequest `
-UseBasicParsing `
-Uri https://dot.net/v1/dotnet-install.ps1 `
-OutFile dotnet-install.ps1; `
./dotnet-install.ps1 `
-InstallDir '/Program Files/dotnet' `
-Channel 3.0 `
-Runtime dotnet; `
Remove-Item -Force dotnet-install.ps1 `
&& setx /M PATH "%PATH%;C:\Program Files\dotnet"