Is it possible to run Windows Containers on Linux? The scenario is based on an app written in the .NET (old net) and the Linux user that wants to run this with Docker to provide a net462
written API on the localhost
.
I am using beta version from Docker Desktop for Windows
If no, then why can Windows run Linux containers and not vice-versa?
EDIT:
As some time has passed and this question is a popular one. I'd like to add one note here that the workaround is to use the new netstandard. It allowed me to pack 4.6.2
framework into new library.
This question is related to
linux
docker
docker-for-windows
windows-container
docker-desktop
As Muhammad Sahputra suggested in this post, it is possible to run Windows OS inside VirtualBox (using VBoxHeadless - without graphical interface) inside Docker container.
Also, a NAT setup inside the VM network configurations can do a port forwarding which gives you the ability to pass-through any traffic that comes to and from the Docker container. This eventually, in a wide perspective, allows you to run any Windows-based service on top of Linux machine.
Maybe this is not a typical use-case of a Docker container, but it definitely an interesting approach to the problem.
For simple applications and maybe more complicated, you can try to use wine inside a docker container.
This docker hub page may help you to achieve your goal.
I hope that Docker will release a native solution soon, like they did with docker-machine on Windows several years ago.
Windows containers are not running on Linux and also You can't run Linux containers on Windows directly.
Unlike Virtualization, containerization uses the same host os. So the container built on linux can not be run on windows and vice versa.
In windows, you have to take help of virtuallization (using Hyper-v) to have same os as your containers's os and then you should be able to run the same.
Docker for windows is similar app which is built on Hyper-v and helps in running linux docker container on windows. But as far as I know, there is nothing as such which helps run windows containers on linux.
No, you cannot run windows containers directly on Linux.
But you can run Linux on Windows.
Windows Server/10 comes packaged with base image of ubuntu OS (after september 2016 beta service pack). That is the reason you can run linux on windows and not other wise. Check out here. https://thenewstack.io/finally-linux-containers-really-will-run-windows-linuxkit/
You can change between OS containers Linux and windows by right clicking on the docker in tray menu.
Containers use the OS kernel. Windows Container utilize processes in order to run. So theoretically speaking Windows Containers cannot run on Linux.
However there are workarounds utilizing VMstyle solutions.
I Have found this solution which uses Vagrant and Packer on Mac, so it should work for Linux as well: https://github.com/StefanScherer/windows-docker-machine
This Vagrant environment creates a Docker Machine to work on your MacBook with Windows containers. You can easily switch between Docker for Mac Linux containers and the Windows containers.
building the headless Vagrant box
$ git clone https://github.com/StefanScherer/packer-windows $ cd packer-windows $ packer build --only=vmware-iso windows_2019_docker.json $ vagrant box add windows_2019_docker windows_2019_docker_vmware.box
Create the Docker Machine
$ git clone https://github.com/StefanScherer/windows-docker-machine $ cd windows-docker-machine $ vagrant up --provider vmware_fusion 2019
Switch to Windows containers
$ eval $(docker-machine env 2019)
You can run MSSQL and .NET Core on Linux, and hence inside Linux containers, nowadays.
See: https://hub.docker.com/r/microsoft/mssql-server-linux/
Also: https://hub.docker.com/r/microsoft/dotnet/
The direct question to your answer, is of course, unless there is a version compiled especially for Linux, no.
You can use Windows Containers inside a virtual machine (the guest OS should match the requirements - Windows 10 Pro or Windows 2016).
For example you can use VirtualBox, just enable Hyper-V inside System / Acceleration / Paravirtualization Interface.
After that if Docker doesn't start up because of an error, use the "Switch to Windows containers..." in the settings.
(this could be moved as a comment to the accepted answer, but I don't have enough reputation to do so)
While Docker for Windows is perfectly able to run Linux containers, the converse, while theoretically possible, is not implemented due to practical reasons.
The most obvious one is, while Docker for Windows can run a Linux VM freely, Docker for Linux would require a Windows license in order to run it inside a VM.
Also, Linux is completely customizable, so the Linux VM used by Docker for Windows has been stripped down to just a few MB, containing only the bare minimum needed to run the containers, while the smallest Windows distribution available is about 1.5 GB. It may not be an impracticable size, but it is much more cumbersome than the Linux on Windows counterpart.
While it is certainly possible for someone to sell a Docker for Linux variation bundled with a Windows license and ready to run Windows containers under Linux (and I don't know if such product exists), the bottom line is that you can't avoid paying Windows vendor lock-in price: both in money and storage space.
We can run Linux containers on Windows. Docker for Windows uses Hyper-v based Linux-Kit or WSL2 as backend to facilitate Linux containers.
If any Linux distribution having this kind of setup, we can run Windows containers. Docker for Linux supports only Linux containers.
Source: Stackoverflow.com