Run asp.net 4.5 in Docker - docker

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.

Related

Regarding Docker cross platform compatibility

I want to ask about cross platform compatibilty of Docker ,means if an application is designed to run in a docker container on windows,then can it run on linux or vice -versa?
Docker was create to run on Linux, so the short answer is yes.
The Windows version isn’t stable or recommend (Docker for windows). At least not by now.
“But, Fischer, I use Docker on Windows!” Yes, with WSL (windows subsystem for linux - Some kind of VM), which you can configure to set a memory limit, using the .wsconfig file, and if you look at your Windows Menu you may found a Ubuntu icon, that connects you to the bash.
Docker is largely used for people that develop software, and today many languanges and frameworks use linux, even Microsoft with .Net runs on Linux.
Docker was created to resolve one simple issue: "But it works on my machine." So, it means that a container should run on every platform. At least "it works on my computer" lol
I think the question is regarding a Windows application. If that's the case, a Windows application cannot simply run on Linux containers. For example, .Net Framework doesn't run on Linux. If an application was targeted for Windows, it needs to run on Windows and in that case only a Windows container can run the application.
Docker Desktop can run both: Windows containers and Linux containers, just not at the same time. You have to switch the context so Docker Desktop can target either WSL (for Linux) or HCS (for Windows).

How to run a portable executable in a docker on linux system

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.

Does docker have a windows container to build windows applications on?

I am on a mac but want to build my application on a windows image. Is this possible with docker? If so what image do I need to use?
The reason I need to build the application on windows is for the code signing and binary building of electron. If this is not possible please let me know.
Since docker is not meant to be a UI for users (though it can be); images for Windows 7, 8, 10, et al are not available. However, Windows Server Core IS available via the Docker Hub.
If you simply need a x86 Win environment to build the application that should do the trick. If you need a full GUI, go Virtual Box or other virtualization tech. Docker containers are meant for single process isolation, ever see windows run only 1 process?
Hope this helps!
Update: It IS possible to run GUI applications via Docker; at least on a Linux host. http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker/
Update2: It is now possible to run Windows applications (CLI or GUI) via Docker: here and here has information regarding the process.

Can I run a .Net web application on Dockers for windows?

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.

Can I use a Windows .Net app with Docker?

I'm a little confused by all the chat about Docker, and how it fits into the virtualisation world. So here's a straight question: can I package up a .Net application (that normally runs on Windows 7 etc) to run in a Docker container, and then execute it on 'any' host supporting Docker?
TIA.
Not today. In future, Microsoft and Docker have announced that you there will be a Windows version of Docker.
Edit: newer info
Note that the base platform and OS have to match - i.e. today you can run ARM Linux containers on ARM Linux and x64 Linux containers on x64 Linux, but you can't mix and match. When Windows is added, the pattern will be the same - you will be able to run Windows containers on Windows OS, but not on Linux. Not without an extra layer of virtualization (like VirtualBox, VMWare, etc).
Edit: respect to the Wine answer, which I hadn't considered. It sort-of fits as "an extra layer of virtualization", but at the OS API level not the hardware level. And somewhat restricted in scope of .Net programs supported.
In a similar vein, you might be able to run your .Net code in Docker using Mono.
Docker builds on Linux. The only way to get the .Net app run in Docker is by using Mono for Linux.
Yes, if you install wine and .NET, here is an example of such a Dockerfile
https://registry.hub.docker.com/u/justmoon/wix/dockerfile/
extract
# Install .NET Framework 4.0
RUN wine wineboot && xvfb-run winetricks --unattended dotnet40 corefonts
This maybe very out of date question, but I think it need a update. Yes you can use docker with .net / .net core and will fully support in Visual Studio 2017.
https://channel9.msdn.com/Events/Connect/2016/172
The be no need to use WINE or Mono.
below is example dockerfile to run .net 4.5 app
FROM microsoft/iis
RUN ["powershell.exe", "Install-WindowsFeature NET-Framework-45-ASPNET"]
RUN ["powershell.exe", "Install-WindowsFeature Web-Asp-Net45"]
ADD publisedDir/ c:\\website
EXPOSE 8081
RUN powershell New-Website -Name 'websiteName' -Port 8081 -PhysicalPath 'c:\website' -ApplicationPool '.NET v4.5'
ENTRYPOINT powershell
A bit late, but still if it helps anyone.
Yes we can run .Net apps on Docker as docker is now supported with Windows natively. But first you have to check your windows version, your windows build must be 14393.233 or greater. Download Docker 1.13.0 or later and then you can easily run a .Net App.
This repository
walks through running a sample .Net App.

Resources