Reputation: 355
I have the following issue. I'm using Windows 10 version 21H1. First I installed Docker desktop, but when I ran it (as Windows container) I ran into hyper-v issues. So finally I followed the steps here: https://poweruser.blog/docker-on-windows-10-without-hyper-v-a529897ed1cc
That helped me at least have a running docker daemon.
Now I'm trying to create a Docker container where I can run .NET (.exe) applications and I can't seem to manage that. First I tried to find a Docker image that corresponds to my local Windows, based on this: https://learn.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility?tabs=windows-server-20H2%2Cwindows-10-21H1
However, having
FROM mcr.microsoft.com/windows/nanoserver:win10-21h1-preview
in my Dockerfile resulted in an error when I ran the Docker image/container:
docker: Error response from daemon: hcs::CreateComputeSystem bb65c4f05b41cb637f2e6cda7a6201aa5af8f51659b299957be0e45eb3e5dab9: The container operating system does not match the host operating system.
The only thing that worked was:
FROM mcr.microsoft.com/windows/nanoserver:2004
but with this image I don't seem to have any tools to run a .NET application; I don't even have the powershell.
So in short, what's the way to run a .NET exe inside a Docker container on Windows 10 ?
Thanks,
Greetings,
Sorin
Upvotes: 0
Views: 1131
Reputation: 3965
There are official .NET Docker images for Windows that you should be using since you're specifically wanting to run a .NET application. For example, you can run the .NET 5 SDK using the following tag: mcr.microsoft.com/dotnet/sdk:5.0
. There are also sample .NET Docker images that demonstrate a pre-made .NET application: mcr.microsoft.com/dotnet/samples:dotnetapp
.
These are all multi-arch/multi-platform tags, meaning that an appropriate version of the Windows image will be pulled based on the version of your host machine. So there's no need to worry about using a specific tag for your version of Windows. However, there are Windows version-specific tags available as well in cases where that's necessary (e.g. 5.0-nanoserver-20H2
).
Upvotes: 1