Can I package up a .Net web application (that normally runs on Windows 7 etc) to run in a Docker container, and then execute it on 'any' host supporting Docker?
Such as Dockers on Linux or Dockers on Windows etc?
You can at least use dotnet core image.
From Getting Started with .NET and Docker:
.NET Core is the open-source version of .NET which is available now. It has a different focus from the full .NET and it’s a modular framework, so you only include the parts you need – the framework itself is composed from NuGet packages.
Before you can run .NET Core apps on a Linux (or OS/X, or Windows) machine, you need to install the DNX runtime. This isn’t the full .NET runtime that we have on Windows; it’s a slimmed-down .NET Execution Environment (DNX).
When you define a Docker image, you start from an existing base image, and the sixeyed/coreclr-base image which is publically available on the Hub already has the DNX installed and configured. To containerize your own .NET Core app, just use that base image and add in your own code.
Related
I'm trying to put a .NET Core 3.1 application listing users in an AD group into a .NET Core Runtime Docker container.
Accessing the AD is being done with the help of a DirectorySearcher from the System.DirectoryServices namespace.
Out of the box, .NET Core doesn't support this namespace, but by adding the package System.DirectoryServices (dotnet add package System.DirectoryServices) installed the required assemblies and the application runs fine on a Win10 machine.
Trying to let the app run in a Linux .Net Core Runtime container throws an exception because DirectoryServices doesn't support this platform.
So I tried using a Windows-based container (tag 3.1.8-nanoserver-2004 to be precise), but then the DirectorySearcher's FindAll() throws the exception
System.DllNotFoundException: Unable to load DLL 'activeds.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)
I've even tried copying the DLL from my host machine into the application's bin directory in the container, but to no avail.
Anyone got an idea what to do to access AD/LDAP from a container?
Since I could not get a Windows Server container to add the Active Directory feature for the life of me, I decided to switch to something different and found LdapForNet
While this works nicely on the dev machine, I also had a hard time finding a way to call the required Bind() to our domain controller from inside a container.
But after half a day of trial and error I found that LdapAuthType.Negotiate worked, but only if I gave the Realm as well:
using (var conn = new LdapConnection()){
conn.Connect(new Uri("LDAP://the.domain.controller"));
conn.Bind(LdapForNet.Native.Native.LdapAuthType.Negotiate,
new LdapCredential {
Realm = "DC=thedomain,DC=com",
UserName = "The user to authenticate",
Password = "Plain text password"
}
);
}
Hope this helps others trying to get LDAP queries running inside a container.
Next stop: Trying the same inside a Linux container.
DirectoryServices will not currently work in Nano Server because the required dependencies are not available. You'll need to use a Windows Server Core image instead. There are not official .NET Core images available for Windows Server Core. (At least not yet. When .NET 5.0 ships, Windows Server Core images will be available for it. See GitHub issue for that proposal.)
You'll need to define your own Dockerfile that uses Windows Server Core as a base image and installs .NET Core in it. There is guidance on how to do this here.
Related links:
Using System.DirectoryServices on a Windows container with ASP.NET Core returns an error
DirectoryServices deployement on nano serve Unable to load activeds.dll
I have a Visual Studio Code app (Angular/.Net Core Web Api app) for work and I can develop, debug and run it on my personal Mac when I VPN into my companies network.
I also have a desktop work PC on my companies site and a remote work server that I can RDP into to do all my work, but I prefer my personal Mac!
I now need to create a .Net Web Api app (NON .Net Core) that my .Net Core app needs to call over http (for WCF web services that won't run on .Net Core), so I created a Visual Studio .Net Framework web Api app on one of my Win PC work machines and I can run both projects side by side (Visual Studio Code and Visual Studio) on my PC but not my Mac.
Is there any way to get the .Net Framework app working on my Mac? ex. in a Docker container or maybe even just running the app in a container, so that my .Net Core app can call it?
Another idea I have but not sure if possible -
When I run the .Net Core app on my Mac I'm VPN'd into my companies network. If I run the .Net Web app on my work desktop or the remote server would I be able to connect to it from my Mac?
Visual Studio Code is a JavaScript application, which is what makes it nice a portable (and also kind of slow). The Visual Studio Framework is a different animal; one that is very territorial. Compiled applications that target the .NET framework will absolutely not run on MacOS, or Linux, or Solaris or..... anything not Windows. .NET core is portable to MacOS though.
As per this post (Can you install and run apps built on the .NET framework on a Mac?) there is the option of using Mono to recompile the code and run it on the Mac. Unfortunately, it does not support the full .NET Framework, and likely requires some non-trivial modifications to the code to make it work. If you go this route, you're either going to be limited to the areas of the Framework that are supported by Mono, or you'll have to maintain 2 different versions of the same code base. Neither option sounds very good to me.
As far as running in Docker, that will not work. Docker is fundamentally tied to the host operating system due to the use of kernel namespaces to provide isolation for processes and other system resources. It does not provide the same kernel API that the .NET Framework would require.
If you are absolutely determined to keep the development work on the Mac, the best option is probably to use a thick virtual machine that runs a full copy of Windows. This has the obvious downsides of being much more expensive (both in terms of the system resources it will need, and the software licensing costs), and you end up using Windows anyway (so you might as well just RDP to a real Windows machine). Probably not the answer you were hoping for (and I would love for someone to list some options that I've missed), but I think you're going to end up doing some work in Windows.
You can't run .NET Framework , because this working with layer architecture from operative system, when running, so many libraries is on migration and now running in .NET core via nuget recomendation is use oficial net core image from microsoft or run you docker over a microsoft server system.
From the microsoft docs:
Docker support is available for ASP.NET projects, ASP.NET Core projects, and .NET Core and .NET Framework console projects.
I've been trying to put together a docker image that supports a UWP application, but struggling to put the build artificacts in the right locations.
Does anyone know if a windows supported Docker image for UWP is in the works?
I am working on a application to deploy challenges for ctfs.
I want to include windows service type challenges, too.
How can I deploy a Portable Executable file on a linux based server?
You can not use docker to run Microsoft Windows. To run Windows executables on linux, you can try to use wine or rely on Virtualization (with a full windows installation inside).
You could also have a look at .net for linux to implement your challenge. This article should get you started if this is what you chose.
I have one project base on asp.net 4.5, now I want run it in Docker. As far as I am known, only asp.net 5 be supported this moment, so has any way let me run my project in Docker?
You must read Mono documentation about ASP.NET MVC Support. Mono can handle your needs, running under Docker Linux Containers.
Using Windows Containers (new feature becomes with Windows Server 2016) you will do that without any trick.
About Mono and Docker, that was useful, stable and can solve your requirements, depends exclusivelly what you are using in your project to understand that is compactible with mono runtime.
Mono Docker repository on Github
Mono on Docker Hub
Enjoy and tell us about your experiences.
There are two approaches depending on whether you want to run Linux or Windows containers. For Linux containers, you'd have to port your app to Mono, as laid out by #luiz-carlos-faria
To run in Windows Docker containers, you'd have to create a 4.6/4.5 base image similar to this one: https://github.com/Microsoft/Virtualization-Documentation/blob/master/windows-container-samples/windowsservercore/dotnet35/Dockerfile
You can run that on Windows Server 2016 TP5 (free download) in a VM.