Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a linux app run on windows using Docker?

I am aware of this question (Can Windows Containers be hosted on linux?), but it doesn't really answer my question.

I am new to Docker, but my question is such - if I take any windows application, put it inside a Docker container, can it run now on Linux and vice versa?

Confluent claims that it can run only on linux, but my colleague installed it on Windows using Docker. So if you can install it with Docker, then the whole application would surely be regarded as cross platform?

I think I am missing some important point here.

like image 545
eddyP23 Avatar asked Sep 11 '17 14:09

eddyP23


People also ask

Can I run the same Docker image on Windows and Linux?

A: No. They cannot. Containers are using the underlying operating system resources and drivers, so Windows containers can run on Windows only, and Linux containers can run on Linux only.

Is it better to run Docker on Windows or Linux?

Use Linux for Containers, it is always the best option. Windows 7 or Windows 10 Home doesn't support Docker, you need to use Docker Toolbox which is not great. There is no support for Windows containers in most cloud providers or Kubernetes.

Can any application run in Docker?

You can run any application in Docker as long as it can be installed and executed unattended, and the base operating system supports the app. Windows Server Core runs in Docker which means you can run pretty much any server or console application in Docker.

Can Docker image run on different OS?

Docker image containers can also run natively on Linux and Windows. However, Windows images can run only on Windows hosts and Linux images can run on Linux hosts and Windows hosts (using a Hyper-V Linux VM, so far), where host means a server or a VM.


1 Answers

Docker is not a VM, it's a way to run applications on a shared kernel that isolate those applications from each other. Windows binaries don't run on a Linux kernel, and vice versa (ignoring the Linux runtime for Windows for the time being). So if you build a container with your Windows application, it will only run if you did so on Dockers Windows runtime and windows base image. It's won't run on a Linux host.

What docker does provide is an embedded VM running Linux (originally this was VirtualBox, but current versions are HyperV). By running Docker for Windows, by default, this VM was used and you would only be running Linux containers, so your windows application would not even run inside the container. To run the Windows binaries, you need to toggle Docker for Windows to use the Windows runtime, and presently that's a toggle, you can't run both Linux and Windows runtimes concurrently on the same host.

There also is no Windows VM packaged with Docker's Linux install. You would need to install your own copy of Windows (and get the licensing which is why Docker doesn't ship this) inside a VM on a Linux host and run your containers inside that VM if you need Windows support.

like image 184
BMitch Avatar answered Sep 22 '22 00:09

BMitch