3

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.

chriscrutt
  • 500
  • 3
  • 5
  • 17
  • I think you misunderstand the concept of Docker. In principle it's just another form to create virtual machines. Inside those you can install any OS you like - and then can run on that OS anything that OS supports (within the constraint of being virtualized). – planetmaker May 21 '17 at 22:26
  • so you could not in essences run a windows program on linux or osx through docker? – chriscrutt May 21 '17 at 22:28
  • Try [Server Fault](http://serverfault.com) – arboreal84 May 21 '17 at 22:40
  • @planetmaker the docker engine does not install any OS inside a VM, it's an environment to isolate applications running on a single kernel. Typically that's a Linux kernel, but windows native support is coming along. Docker does use VMs on their windows and mac installs to run a Linux OS on which the docker engine can then run. – BMitch May 22 '17 at 00:01
  • aye, thx for the explanation – planetmaker May 22 '17 at 08:29
  • You can create Docker Windows containers only on a Windows host, which limits you to Windows 10 pro and Windows Server 2016. You can run a Linux container on a Windows host using Docker for Windows or Docker Toolbox – Mano Marks May 22 '17 at 19:41

2 Answers2

6

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.

BMitch
  • 231,797
  • 42
  • 475
  • 450
  • This answer seems outdated. There are now windows base os images, such as nanoserver or servercore. – Gregoire Cattan Jan 13 '22 at 19:09
  • @HugoZevetel there are windows images, but they must be run on a windows host. The OP is asking to run Windows binaries on a Linux or OSX hosts. – BMitch Feb 04 '22 at 13:55
  • Yes, you need a windows host, but I believe this can still be achieved with docker. https://stackoverflow.com/questions/36172382/how-to-run-a-windows-docker-container-on-linux-host – Gregoire Cattan Feb 05 '22 at 19:26
  • @HugoZevetel per the question "and I would like to run it on either Linux or OSX by creating a Docker." I believe you want to answer a different question than what's being asked here. – BMitch Feb 05 '22 at 19:53
  • No. Your answer recommends skipping docker and running on a Windows VM. What I say, and what the link above says, is that it is possible to use docker to run a Windows container on Linux, which is exactly the question. Please, check the link above. – Gregoire Cattan Feb 05 '22 at 20:12
  • @HugoZevetel if you have that working, then you should post a competing answer rather than disagreeing in the comments. My read of VonC's answer is the same as mine, if the host is Linux, then you need a VM, or perhaps wine, to run the windows binary. – BMitch Feb 05 '22 at 20:32
  • No. The answer of VonC says you might use k8s to do so. And 1 comment and 1 answer suggest using QUEMU with Docker. I did not disagree with your post. I just said it might need to be updated, as 1) it is now possible to encapsulate .exe in Windows container and 2) to run windows containers on Linux. – Gregoire Cattan Feb 05 '22 at 21:50
  • @hugozevetel if you have that working, then please post your own answer. – BMitch Feb 05 '22 at 22:48
2

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

Michael Innes
  • 2,045
  • 5
  • 25
  • 41