'Create a Linux-based Docker file for .NET Framework project

I have an ASP.Net Framework 4.8 project. I want to create a Linux-based Docker file for this project, but I can't find a Linux-based image to use as a base image in my Docker file for .NET Framework. How can I create a Docker file for this?



Solution 1:[1]

.NET Framework is not cross-platform. Neither is ASP.NET itself. They do not work on Linux. So there are no Linux-based container images that would let you run .NET Framework or ASP.NET Framework.

And you can not make a custom one; .NET Framework will simply not run on Linux.

That's why Microsoft created .NET Core (and now just called .NET) and ASP.NET Core, so they would be cross-platform and you could use those on Linux, including Linux-based container images.


As suggested in some comments, you might be able to use mono. Mono is a (not really supported) implementation of .NET Framework that aims to work on Linux. It's not 100% bug for bug compatible with .NET Framework, so your application may or may not work with it.


A better, but more difficult option, would be to port your application to ASP.NET Core 6, which is supported on Linux-based containers.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 omajid