- Linux containers on Windows 10
- Linux containers in a Moby VM
- Начало работы. Настройка контейнеров Linux в Windows 10 Get started: Set up Linux Containers on Windows 10
- Предварительные условия Prerequisites
- Установка Docker Desktop Install Docker Desktop
- Запуск первого контейнера Linux Run Your First Linux Container
- Контейнеры Linux в Windows 10 Linux containers on Windows 10
- Контейнеры Linux на виртуальной машине Moby Linux containers in a Moby VM
- Switch between windows and linux containers
- Asked by:
- Question
- All replies
- Can Windows Containers be hosted on linux?
- 10 Answers 10
Linux containers on Windows 10
Linux containers make up a huge percent of the overall container ecosystem and are fundamental to both developer experiences and production environments. Since containers share a kernel with the container host, however, running Linux containers directly on Windows isn’t an option. This is where virtualization comes into the picture.
Linux containers in a Moby VM
To run Linux containers in a Linux VM, follow the instructions in Docker’s get-started guide.
Docker has been able to run Linux containers on Windows desktop since it was first released in 2016 (before Hyper-V isolation or Linux containers on Windows were available) using a LinuxKit based virtual machine running on Hyper-V.
In this model, Docker Client runs on Windows desktop but calls into Docker Daemon on the Linux VM.
In this model, all Linux containers share a single Linux-based container host and all Linux containers:
- Share a kernel with each other and the Moby VM, but not with the Windows host.
- Have consistent storage and networking properties with Linux containers running on Linux (since they are running on a Linux VM).
It also means the Linux container host (Moby VM) needs to be running Docker Daemon and all of Docker Daemon’s dependencies.
To see if you’re running with Moby VM, check Hyper-V Manager for Moby VM using either the Hyper-V Manager UI or by running Get-VM in an elevated PowerShell window.
Начало работы. Настройка контейнеров Linux в Windows 10 Get started: Set up Linux Containers on Windows 10
Это упражнение охватывает создание и запуск контейнеров Linux в Windows 10. The exercise will walk through creating and running Linux containers on Windows 10.
В рамках этого краткого руководства вы сможете выполнить следующие действия: In this quick start you will accomplish:
- Установка Docker Desktop Installing Docker Desktop
- Запуск простого контейнера Linux Running a simple Linux container
Это краткое руководство применимо только к Windows 10. This quick start is specific to Windows 10. Дополнительную документацию по быстрому началу работы можно найти в содержании в левой части этой страницы. Additional quick start documentation can be found in the table of contents on the left-hand side of this page.
Предварительные условия Prerequisites
Убедитесь, что ваша система отвечает следующим требованиям: Please make sure you meet the following requirements:
- Одна физическая компьютерная система под управлением Windows 10 Профессиональная, Windows 10 Корпоративная или Windows Server 2019 версии 1809 или более поздней версии. One physical computer system running Windows 10 Professional, Windows 10 Enterprise, or Windows Server 2019 version 1809 or later
- Убедитесь, что включена технология Hyper-V. Make sure Hyper-V is enabled.
Установка Docker Desktop Install Docker Desktop
Скачайте Docker Desktop и запустите установщик (вам потребуется войти в систему Download Docker Desktop and run the installer (You will be required to login. и создать учетную запись, если у вас ее еще нет). Create an account if you don’t have one already). Подробные инструкции по установке доступны в документации по Docker. Detailed installation instructions are available in the Docker documentation.
Запуск первого контейнера Linux Run Your First Linux Container
Чтобы запустить контейнеры Linux, необходимо убедиться в ориентировании Docker на требуемую управляющую программу. In order to run Linux containers, you need to make sure Docker is targeting the correct daemon. Чтобы проверить это, щелкните значок Docker с изображением кита на панели задач и выберите Switch to Linux Containers в меню действий. You can toggle this by selecting Switch to Linux Containers from the action menu when clicking on the Docker whale icon in the system tray. Если вы видите Switch to Windows Containers , в качестве целевой уже задана управляющая программа Linux. If you see Switch to Windows Containers , then you are already targeting the Linux daemon.
Убедившись в ориентировании на требуемую управляющую программу, запустите контейнер с помощью следующей команды: Once you’ve confirmed you are targeting the correc daemon, run the container with the following command:
Должен запуститься контейнер и отобразиться текст «hello_world». Затем будет выполнен выход. The container should run, print «hello_world», then exit.
При запросе docker images должен отобразиться образ контейнера Linux, который вы только что извлекли и запустили: When you query docker images , you should see the Linux container image that you just pulled an ran:
Контейнеры Linux в Windows 10 Linux containers on Windows 10
Контейнеры Linux составляют огромную долю общей экосистемы контейнеров и имеют важное значение для разработки и рабочих сред. Linux containers make up a huge percent of the overall container ecosystem and are fundamental to both developer experiences and production environments. Так как контейнеры и узел контейнеров используют одно ядро, запуск контейнеров Linux непосредственно в Windows — не лучший вариант. Since containers share a kernel with the container host, however, running Linux containers directly on Windows isn’t an option. Как раз в таких случаях и применяется виртуализация. This is where virtualization comes into the picture.
Контейнеры Linux на виртуальной машине Moby Linux containers in a Moby VM
Чтобы запустить контейнеры Linux на виртуальной машине Linux, выполните инструкции из статьи о начале работы с Docker. To run Linux containers in a Linux VM, follow the instructions in Docker’s get-started guide.
Docker поддерживает запуск контейнеров Linux на компьютерах с Windows с момента своего первого запуска в 2016 г. (до того, как стали доступны изоляция Hyper-V или контейнеры Linux в Windows). Для этого используется виртуальная машина на базе LinuxKit, работающая в Hyper-V. Docker has been able to run Linux containers on Windows desktop since it was first released in 2016 (before Hyper-V isolation or Linux containers on Windows were available) using a LinuxKit based virtual machine running on Hyper-V.
В такой модели клиент Docker запускается на компьютере с Windows, но отправляет вызовы в управляющую программу Docker на виртуальной машине Linux. In this model, Docker Client runs on Windows desktop but calls into Docker Daemon on the Linux VM.
В этой модели все контейнеры Linux совместно используют один узел контейнера, а также: In this model, all Linux containers share a single Linux-based container host and all Linux containers:
- используют одно ядро совместно с виртуальной машиной Moby, но не с узлом Windows; Share a kernel with each other and the Moby VM, but not with the Windows host.
- имеют согласованные свойства сети и хранилища между контейнерами Linux, работающими в Linux (так как они работают на виртуальной машине Linux). Have consistent storage and networking properties with Linux containers running on Linux (since they are running on a Linux VM).
Это также означает, что в узле контейнера Linux (виртуальной машине Moby) должна быть запущена управляющая программа Docker и все ее зависимости. It also means the Linux container host (Moby VM) needs to be running Docker Daemon and all of Docker Daemon’s dependencies.
Чтобы узнать, используется ли виртуальная машина Moby, проверьте в диспетчере Hyper-V ее наличие с помощью пользовательского интерфейса или выполните команду Get-VM в окне PowerShell с повышенными привилегиями. To see if you’re running with Moby VM, check Hyper-V Manager for Moby VM using either the Hyper-V Manager UI or by running Get-VM in an elevated PowerShell window.
Switch between windows and linux containers
This forum is closed. Thank you for your contributions.
Asked by:
Question
I Installed docker on Windows Server 2016.
Now the container runs per default as windows container but i want to have it running linux container.
On My desktop machine I’ve a tray icon where i can switch this. but on there server there isn’t one
So what do i have to do tochange to linux container or how to get the tray icon?
All replies
I think that will do it.
I face the similar issue. Any idea how to make linux containers work on windows server 2016?
You cannot run Linux containers on Windows server 2016 yet. Microsoft announced Linux Containers on windows server 2016 using windows hyper-v containers. There is no release date for that yet.
On windows 10, using «Docker for Windows», Linux containers run inside a full Hyper-v VM.
This issue is still very difficult to overlook.
There seems to be some workarounds, but I hoped that the official Docker software would support Linux containers on Windows Server 2016.
The release notes for Docker EE 17.06 say «Docker EE is functionally equivalent to the corresponding Docker CE that it references». But I still can’t see any switch to Linux containers.
In the meantime there is also a Docker CE version from the edge channel which should work on Windows Server 2016. But the latest 17.07.0-ce-rc-win32 (13024) version does even not start on Windows Server 2016 or refuses to start as soon I switch to Linux containers (Error Message: «Error response from daemon: Bad response from Docker engine at Docker.Backend.DockerDaemonChecker.Check(Func`1 isDaemonProcessStillRunning. «)
It is also not clear if it is possible to have Docker EE and Docker CE side by side on Windows Server 2016.
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.
10 Answers 10
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.