Windows docker containers on linux

TL;DR:

Q: Can Windows containers run on 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.

Q: But what about Docker for Windows? Or other VM-based solutions?

A: Docker for Windows allows you to simulate running Linux containers on Windows, but under the hood a Linux VM is created, so still Linux containers are running on Linux, and Windows containers are running on Windows.

Bonus: Read this very nice article about running Linux docker containers on Windows.

Q: So, what should I do with a .NET Framework 462 application, if I would like to run in a container?

A: It depends. Consider the following recommendations:

  • If it is possible, move to .NET Core. Since .NET Core brings support to most major features of .NET Framework, and .NET Framework 4.8 will be the last version of .NET framework

  • If you cannot migrate to .NET Core — As @Sebastian mentioned — you can convert your libraries to .NET Standard, and have two versions of the application — one on .NET Framework 4.6.2, and one on .NET Core — it is not always obvious. Visual Studio supports it pretty well (with multi-targeting), but some dependencies can require extra care.

  • (Less recommended) In some cases, you can run Windows containers. Windows containers are becoming more and more mature, with better support in platforms like Kubernetes. But to be able to run .NET Framework code, you still need to run on base image of «Server Core», which occupies about 1.4 GB. In same rare cases, you can migrate your code to .NET Core, but still run on Windows Nano server, with an image size of 95 MB.

Leaving also the old updates for history

Update 2: 08.2018

If you are using Docker-for-Windows, you can run now both Windows and Linux containers simultaneously: Running Docker Windows and Linux Containers Simultaneously

Bonus: Not directly related to the question, but you can now run not only the Linux container itself, but also an orchestrator like Kubernetes: Kubernetes is Now Available In Docker Desktop Stable Channel

Updated at 2018:

Original answer in general is right, BUT several months ago, Docker added experimental feature LCOW (official GitHub repository).

From this post:

Doesn’t Docker for Windows already run Linux containers? That’s right.
Docker for Windows can run Linux or Windows containers, with support
for Linux containers via a Hyper-V Moby Linux VM (as of Docker for
Windows 17.10 this VM is based on LinuxKit).

The setup for running Linux containers with LCOW is a lot simpler than
the previous architecture
where a Hyper-V Linux VM runs a Linux Docker
daemon, along with all your containers. With LCOW, the Docker daemon
runs as a Windows process (same as when running Docker Windows
containers), and every time you start a Linux container Docker
launches a minimal Hyper-V hypervisor running a VM with a Linux
kernel, runc and the container processes running on top.

Because there’s only one Docker daemon, and because that daemon now
runs on Windows, it will soon be possible to run Windows and Linux
Docker containers side-by-side, in the same networking namespace
. This
will unlock a lot of exciting development and production scenarios for
Docker users on Windows.

Original:

As mentioned in comments by @PanagiotisKanavos, containers are not for virtualization, and they are using the resources of the host machine. As a result, for now a Windows container cannot run «as-is» on a Linux machine.

But — you can do it by using VM — as it works on Windows. You can install a Windows VM on your Linux host, which will allow to run Windows containers.

With it, IMHO running it this way in a production environment will not be the best idea.

Also, this answer provides more details.

Running a Windows Docker container on a Linux host can be a challenging task, as the two operating systems have different architectures and require different configurations. However, it is possible to run a Windows container on a Linux host using a few different methods. These methods include using virtualization software, using the Windows Subsystem for Linux (WSL), and using a tool like Docker Machine.

Method 1: Virtualization Software

To run a Windows Docker container on a Linux host, you can use virtualization software like VirtualBox or VMware. Here are the steps to follow:

  1. Install virtualization software on your Linux host. In this example, we will use VirtualBox.

  2. Download the Windows Docker image from the Docker Hub registry:

    docker pull mcr.microsoft.com/windows/servercore:ltsc2019
  3. Create a new virtual machine in VirtualBox with the following settings:

    • Name: Windows Container
    • Type: Microsoft Windows
    • Version: Windows Server 2019 (64-bit)
    • Memory: 4 GB
    • Hard disk: Create a new virtual hard disk with at least 30 GB of space
  4. Start the virtual machine and install Docker Desktop for Windows.

  5. Open a PowerShell console in the virtual machine and run the following command to switch Docker to use Windows containers:

    & $Env:ProgramFiles\Docker\Docker\DockerCli.exe -SwitchDaemon
  6. Pull the Windows Docker image again to make sure it’s available for the Windows Docker daemon:

    docker pull mcr.microsoft.com/windows/servercore:ltsc2019
  7. Run the Windows Docker container:

    docker run -it mcr.microsoft.com/windows/servercore:ltsc2019 cmd

    This will start a command prompt inside the Windows Docker container.

That’s it! You can now use a Windows Docker container on your Linux host using virtualization software.

Method 2: Windows Subsystem for Linux (WSL)

To run a Windows Docker container on a Linux host using Windows Subsystem for Linux (WSL), follow these steps:

  1. Install Docker on your Linux host and make sure it is running properly.
  2. Install WSL on your Windows machine and make sure it is running properly.
  3. Open a WSL terminal and run the following command to download the Windows Docker image:
docker pull mcr.microsoft.com/windows/servercore:ltsc2019
  1. Run the following command to start the container:
docker run -it mcr.microsoft.com/windows/servercore:ltsc2019 cmd.exe
  1. You should now be inside the container’s command prompt. To exit the container, simply type «exit».

That’s it! You have successfully run a Windows Docker container on a Linux host using Windows Subsystem for Linux (WSL).

Note: You may need to enable virtualization in your BIOS settings for this to work properly.

Code Examples:

docker pull mcr.microsoft.com/windows/servercore:ltsc2019
docker run -it mcr.microsoft.com/windows/servercore:ltsc2019 cmd.exe

Method 3: Docker Machine

To run a Windows Docker container on a Linux host using Docker Machine, you can follow these steps:

  1. Install Docker Machine on your Linux host machine.

  2. Create a new Docker Machine with the «virtualbox» driver. This will create a virtual machine that will act as the host for the Windows Docker container.

docker-machine create --driver virtualbox windows
  1. Set the environment variables for the new Docker Machine.
eval $(docker-machine env windows)
  1. Pull the Windows Docker image from the Docker Hub.
docker pull mcr.microsoft.com/windows/servercore:ltsc2019
  1. Run the Windows Docker container on the new Docker Machine.
docker run -it mcr.microsoft.com/windows/servercore:ltsc2019 cmd
  1. You can now interact with the Windows container as if it were running on a Windows host.

Note: Make sure that your Linux host machine has enough resources to run the virtual machine and the Windows Docker container.

That’s it! With Docker Machine, you can easily run a Windows Docker container on a Linux host machine.

No, you cannot run Windows containers directly on Linux. But you can run Linux on Windows. You can change between OS containers Linux and Windows by right-clicking on the docker in the tray menu. Containers use the OS kernel.

Can I run Windows in a Docker container?

The Docker daemon provides each container with any necessary kernel-level properties so that the containerized application can run. The Windows Docker Desktop has the feature of providing a Linux Subsystem; and in this case, running a Linux container can ultimately run on Windows.

Also Read: What does ps mean in Docker ps?

Can I run Windows 10 in a Docker?

Docker works cross-platform and such supports execution on a Windows host, including Windows 10 (Pro or Enterprise). This makes Windows 10 a perfect development environment for Docker use-cases. On top of this, Windows is also the only platform, for now at least, that can run Windows and Linux based containers.

Do containers run on Linux?

You can run both Linux and Windows programs and executables in Docker containers. The Docker platform runs natively on Linux (on x86-64, ARM and many other CPU architectures) and on Windows (x86-64). Docker Inc. builds products that let you build and run containers on Linux, Windows and macOS.

What is Kubernetes vs Docker?

A fundamental difference between Kubernetes and Docker is that Kubernetes is meant to run across a cluster while Docker runs on a single node. Kubernetes is more extensive than Docker Swarm and is meant to coordinate clusters of nodes at scale in production in an efficient manner.

What is Kubernetes vs Docker?

Is Docker better Windows or Linux?

From a technical standpoint, there is no real difference between using Docker on Windows and Linux. You can achieve the same things with Docker on both platforms. I don’t think you can say that either Windows or Linux is “better” for hosting Docker.

Can Docker containers have different OS?

No, it does not. Docker uses containerisation as a core technology, which relies on the concept of sharing a kernel between containers. If one Docker image relies on a Windows kernel and another relies on a Linux kernel, you cannot run those two images on the same OS.

Is Hyper-V required for Docker?

README for Docker Toolbox and Docker Machine users: Microsoft Hyper-V is required to run Docker Desktop. The Docker Desktop Windows installer enables Hyper-V if required, and restarts your machine.

Is Docker better than VM?

Though Docker and virtual machines have their advantages over hardware devices, Docker is the more efficient of the two in terms of resource utilization. If two organizations were completely identical and running the same hardware, then the company using Docker would be able to sustain more applications.

How can I tell if Docker is running on Linux?

The operating-system independent way to check whether Docker is running is to ask Docker, using the docker info command. You can also use operating system utilities, such as sudo systemctl is-active docker or sudo status docker or sudo service docker status , or checking the service status using Windows utilities.

How do Containers run on Linux?

Linux containers run natively on the operating system, sharing it across all of your containers, so your apps and services stay lightweight and run swiftly in parallel. Linux containers are another evolutionary leap in how we develop, deploy, and manage applications.

How do I use containers in Linux?

How to start using containers on Linux

  1. Install LXC: sudo apt-get install lxc.
  2. Create a container: sudo lxc-create -t fedora -n fed-01.
  3. List your containers: sudo lxc-ls.
  4. Start a container: sudo lxc-start -d -n fed-01.
  5. Get a console for your container: sudo lxc-console -n fed-01.

Can we run Windows Docker container on Linux?

No, Windows Docker containers cannot be run directly on Linux. Docker containers are based on the host operating system, and Linux and Windows have different container runtimes. However, you can use Linux containers on Linux and Windows containers on Windows. To run a Windows Docker container on Linux, you would need to use virtualization or a compatibility layer like WSL 2 (Windows Subsystem for Linux) to create a Linux environment within which you can run the Linux Docker engine and Linux containers.

Can I run a Windows container on Docker?

  • Yes, Docker supports running Windows containers.
  • You can run Windows containers on a Windows host using Docker.
  • Ensure that your Windows host is running a compatible version of Windows and Docker Engine.
  • You can use Docker CLI commands or Docker Compose to manage and run Windows containers.

Can a Docker container run on any OS?

  • No, a Docker container cannot run on any OS.
  • Docker containers are platform-dependent and require a compatible operating system.
  • Containers are based on the host’s operating system kernel.
  • Therefore, you can run Docker containers on an OS that is compatible with the container runtime, such as Linux containers on a Linux host and Windows containers on a Windows host.

Read More Posts

  • How do I put Docker on my desktop Windows 10 home?
  • Best answer: How do I install Dockers on Windows 10?
  • Can I run Linux on Docker?
  • Are all Docker containers Linux?
  • Your question: Which Linux OS is best for Docker?
  • Can you run Docker on Linux?

Can Windows Containers be hosted on linux?

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?

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.

9 Answers 9

Update3: 06.2019 Some of the comments says that the answer is not clear, I’ll try to clarify.

Q: Can Windows containers run on 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.

Q: But what about Docker for Windows? Or other VM-based solutions?

A: Docker for Windows allows you to simulate running Linux containers on Windows, but under the hood a Linux VM is created, so still Linux containers are running on Linux, and Windows containers are running on Windows.

Bonus: Read this very nice article about running Linux docker containers on Windows.

Q: So, what should I do with a .Net Framework 462 app, if I would like to run in a container?

A: It depends. Following several recommendations:

    If it is possible — move to .Net Core. Since .Net Core brings support to most major features of .Net Framework, and .Net Framework 4.8 will be the last version of .Net framework

If you cannot migrate to .Net Core — As @Sebastian mentioned — you can convert your libraries to .Net Standard, and have 2 versions of app — one on .Net Framework 4.6.2, and one on .Net Core — it is not always obvious, Visual Studio supports it pretty well (with multi-targeting), but some dependencies can require extra care.

(Less recommended) In some cases, you can run windows containers. Windows containers are becoming more and more mature, with better support in platforms like Kubernetes. But to be able to run .Net Framework code, you still need to run on base image of «Server Core», which occupies about 1.4 GB. In same rare cases, you can migrate your code to .Net Core, but still run on Windows Nano servers, with an image size of 95 MB.

Leaving also the old updates for history

Update2: 08.2018 If you are using Docker-for-Windows, you can run now both windows and linux containers simultaneously: https://blogs.msdn.microsoft.com/premier_developer/2018/04/20/running-docker-windows-and-linux-containers-simultaneously/

Bonus: Not directly related to the question, but you can now run not only the linux container itself, but also orchestrator like kubernetes: https://blog.docker.com/2018/07/kubernetes-is-now-available-in-docker-desktop-stable-channel/

Updated at 2018:

Original answer in general is right, BUT several months ago, docker added experimental feature LCOW (official github repository).

Doesn’t Docker for Windows already run Linux containers? That’s right. Docker for Windows can run Linux or Windows containers, with support for Linux containers via a Hyper-V Moby Linux VM (as of Docker for Windows 17.10 this VM is based on LinuxKit).

The setup for running Linux containers with LCOW is a lot simpler than the previous architecture where a Hyper-V Linux VM runs a Linux Docker daemon, along with all your containers. With LCOW, the Docker daemon runs as a Windows process (same as when running Docker Windows containers), and every time you start a Linux container Docker launches a minimal Hyper-V hypervisor running a VM with a Linux kernel, runc and the container processes running on top.

Because there’s only one Docker daemon, and because that daemon now runs on Windows, it will soon be possible to run Windows and Linux Docker containers side-by-side, in the same networking namespace. This will unlock a lot of exciting development and production scenarios for Docker users on Windows.

Original:

As mentioned in comments by @PanagiotisKanavos, containers are not for virtualization, and they are using the resources of the host machine. As a result, for now windows container cannot run «as-is» on linux machine.

But — you can do it by using VM — as it works on windows. You can install windows VM on your linux host, which will allow to run windows containers.

With it, IMHO run it this way on PROD environment will not be the best idea.

Источник

Можно ли запустить Windows приложение в Linux Docker container?

Возможно глупый вопрос, но всё же.
Есть машинка с Debian, на ней установлен Docker CE.
И мой вопрос — можно ли запустить в контейнере Docker Windows приложение (например я хочу попробовать www.passmark.com/products/pt.htm)
EN-форумы утверждают, что нет, но это было до выхода Docker for Windows.
Сейчас же на странице Docker висит красивая диаграмма, утверждающая, что можно запустить любое приложение на любой ОС, но видимо речь о собственных приложениях 🙂

You can run Windows-based containers on Windows Server 2016 and Windows 10. Windows-based containers require a Windows kernel to run, in the same way that Linux-based containers require a Linux kernel to run. You can even run Windows-based containers on a Windows virtual machine running on an macOS or Linux host. Docker Machine is not necessary if you run macOS 10.10.3 Yosemite, Windows Server 2016, or Windows 10.

Нет.
Докер — это не особо большая НАДСТРОЙКА над ядром Линукса.

Он просто удобным способом позволяет изолировать и запускать родные приложения Линукса.
Из неродных вариантов — разве только запуск Линуксовых приложений из под Докера ФриБСД или напротив запуск Фришных приложение из под Докера Линуха — так как эти операционные системы близки.

С Виндовс сие невозможно в принципе.
Тот Докер что устанавливается в Виндовс — тянет за собой полноценный Линукс. И только это делает возможным запуска Линукс приложений в Докере Виндовс.

Обратная процедура также нетривиальна.

Если вам нужен аналог Докера для запуска приложений Виндовс — обратитесь к технологии Windows Container.

Источник

Preview: Linux Containers on Windows

Microsoft is getting ready for the next big update for Windows Server (check out today’s complimentary Microsoft blog post ) and some of the new features are very exciting for Docker users. One of the most important enhancements is that Docker can now run Linux containers on Windows (LCOW), using Hyper-V technology.

Running Docker Linux containers on Windows requires a minimal Linux kernel and userland to host the container processes. This is exactly what the LinuxKit toolkit was designed for: creating secure, lean and portable Linux subsystems that can provide Linux container functionality as a component of a container platform.

We’ve been busy prototyping LinuxKit support for Docker Linux containers on Windows and have a working preview for you to try. This is still a work in progress, and requires either the recently announced “Windows Server Insider” or Windows 10 Insider builds.

UPDATE: LCOW support is available in Windows 10 Fall Creators Update and in Windows Server 1709. The simplest way to try it out on Windows 10 is to install the edge variant of Docker for Windows (details). On Windows Server 1709, install EE preview.

Running Docker Linux Containers on Windows with LinuxKit

The instructions below have been tested on Windows 10 and Windows Server Insider builds 16278 and 16281.

Be sure to install Docker for Windows (Windows 10) or Docker Enterprise Edition (Windows Server Insider) before starting.

Setup Docker and LinuxKit

A preview build of LinuxKit is available by simply running the following commands in PowerShell (with Administrator rights):

Now get a master branch build of the Docker daemon that contains preview support for Linux containers on Windows:

Start a new Docker daemon listening on a separate pipe and using a separate storage location from the default install:

Try it

Run a Linux container:

Docker just launched a minimal VM running a LinuxKit instance hosting the Linux container!

Since this is an early preview there are some limitations, but basic Docker operations like pull and run work.

Looking ahead

Both Windows Server Insider builds and Docker support for Linux containers on Windows are in early preview mode. When GA, Docker Linux containers on Windows will improve the Docker Linux container experience for both Windows developers and server administrators. Developers will be able to more easily build and test mixed Windows/Linux Docker applications by running containers for both platforms side-by-side on the same system.

And IT-admins that prefer Windows will soon be able to easily run (mostly) Linux-only software like HAProxy and Redis on Windows systems by way of Docker Linux containers on Windows. For example, Docker Linux containers on Windows will make setting up Docker Enterprise Edition and Universal Control Plane (which relies on some Linux-only components) on Windows Server much simpler.

We hope this LinuxKit-based walkthrough will set you up to start experimenting. Feedback is always welcome! For general help and getting started with Insider builds use the Windows Feedback Hub (Windows 10), or the Windows Server Insiders Tech Community . For issues with LinuxKit and Docker support for Linux containers on Windows use the Docker for Windows issue tracker on GitHub . And let us know on Twitter if you build something cool!

Источник

can we run a windows docker container on linux host? also can take a RDP to windows docker container hosted on linux from other windows machines in the same network?

Can you run Windows in a Docker container?

You can run both Linux and Windows programs and executables in Docker containers. The Docker platform runs natively on Linux (on x86-64, ARM and many other CPU architectures) and on Windows (x86-64). Docker Inc. builds products that let you build and run containers on Linux, Windows and macOS.

How do I run a Windows program in a container?

First, open the container host you want to manage, and in the Tools pane, select the Containers extension. Then, select the Images tab inside the Container extension under Container Host. In the Pull Container Image settings, provide the image URL and the tag.

Can Docker run Linux containers?

That’s right. Docker for Windows can run Linux or Windows containers, with support for Linux containers via a Hyper-V Moby Linux VM (as of Docker for Windows 17.10 this VM is based on LinuxKit).

How do I run two Docker containers at the same time?

Docker -> Settings –> Daemon With Docker for Windows started and Windows containers selected, you can now run either Windows or Linux Containers simultaneously. The new –platform=linux command line switch is used to pull or start Linux images on Windows. Now start the Linux container and a Windows Server Core container.

Is it possible to run a Windows container on Linux?

«windows docker»: if that means docker for windows, running Windows container, then no. You could run windows container on Linux the same way you are running Linux Container on windows: through a Virtual Machine emulating the target host. A docker-compose that handles both qemu and preinstalled isos might be possible.

Can I run Docker on a Windows Nano Server?

In same rare cases, you can migrate your code to .NET Core, but still run on Windows Nano server, with an image size of 95 MB. If you are using Docker-for-Windows, you can run now both windows and Linux containers simultaneously: Running Docker Windows and Linux Containers Simultaneously

Today, it is clearly possible.

I recently succeeded in containerizing Windows Guest using QEMU and Docker.

https://github.com/gnh1201/docker-qemu/wiki/Windows-Guest

«windows docker»: if that means docker for windows, running Windows container, then no.

You could run windows container on Linux the same way you are running Linux Container on windows: through a Virtual Machine emulating the target host.

Update Dec. 2016: Kubernetes 1.5 might offer a solution: see «Linux machine with docker deploy windows container»

  • Windows did not detect network adapter
  • Windows did not shut down successfully if this was due to the system not responding
  • Windows dictation скачать на русском
  • Windows docker container on linux
  • Windows do not go to sleep