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

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.

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).

Base Docker image from existing Windows machine

We have a large application with several parts running on a Windows VM and I am trying to evaluate Docker containers for our application deployment. Is it possible to create a base docker image from an existing Windows VM already running my application? (I know this can be done using Dockerfile but I am looking for a quick way to create the image)
https://docs.docker.com/engine/userguide/eng-image/baseimages/
Above link describes creating image from working machine for Linux, but I am looking for something similar for Windows.
The only base image for Windows that I know are the ones proposed by Microsoft, for Windows Server 2016 or 1709.
See "PoC: How to build images for 1709 without 1709"
That means you can translate any Widows VM into an image.
You would need:
a Dockerfile
the right Microsoft base image, which would represent a Windows server one.
Typically:
microsoft/nanoserver,
microsoft/windowsservercore
If you application only runs on a Windows VM, you need to make sure it can be installed and run on one of those base Windows images.
EVen though you are using a VM Windows server 2016, you would not be able to quickly "capture its state": you need a Dockerfile to describe what you want your Widows container to run.
No it's not possible. You have some stuff like Vm2Docker etc but all it does the same thing you will do manually that is enumerate features installed and create some artifacts for you.
But it's not possible to do for third party application as you mentioned. You'd have to disassemble it and figure out how to scripts to install it.
I am looking for a way to have a Development environment of Production web server for our Developers/testers created using Docker on windows.
I have windows server 2016 OS installed on a Physical server (not VM), and want to dockerize it so that Dev team can make changes on it first and once they confirm all working fine then same changes will be done on production web server.
Thanks,
RK.

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.

How do you run an .exe file on Docker?

I am currently trying to understand and learn Docker. I have an app, .exe file, and I would like to run it on either Linux or OSX by creating a Docker. I've searched online but I can't find anything allowing one to do that, and I don't know Docker well enough to try and improvise something. Is this possible? Would I have to use Boot2Docker? Could you please point me in the right direction? Thank you in advance any help is appreciated.
Docker allows you to isolate applications running on a host, it does not provide a different OS to run those applications on (with the exception of a the client products that include a Linux VM since Docker was originally a Linux only tool). If the application runs on Linux, it can typically run inside a container. If the application cannot run on Linux, then it will not run inside a Linux container.
An exe is a windows binary format. This binary format incompatible with Linux (unless you run it inside of an emulator or VM). I'm not aware of any easy way to accomplish your goal. If you want to run this binary, then skip Docker on Linux and install a Windows VM on your host.
As other answers have said, Docker doesn't emulate the entire Windows OS that you would need in order to run an executable 'exe' file. However, there's another tool that may do something similar to what you want: "Wine" app from WineHQ. An abbreviated summary from their site:
Wine is a compatibility layer capable of running Windows applications
on several operating systems, such as Linux and macOS.
Instead of simulating internal Windows logic like a virtual
machine or emulator, Wine translates Windows API calls
on-the-fly, eliminating the performance and memory penalties of
other methods and allowing you to cleanly integrate Windows
applications into your desktop.
(I don't work with nor for WineHQ, nor have I actually used it yet. I've only heard of it, and it seems like it might be a solution for running a Windows program inside of a light-weight container.)

Run asp.net 4.5 in 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.

Resources