Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If Docker runs natively on windows, then why does it need hyper-v

If Docker community runs natively on windows, then why does it need Hyper-v? I.E., doesn't native imply that Docker-Engine can run instructions on windows? It looks to me like it still starts up a Linux VM and runs with-in that.

To me, is seems that docker-toolbox uses an oracle hyper-visor running linux, while Docker community uses Hyper-V running linux. Is there another important difference that I'm overlooking?

Is this correct? Am I understanding the word "native" wrong, is docker mis-using the word, or is there some other aspect I'm missing?

The reason I'm asking, is because I noticed that you don't use Docker-machine with the community edition, and I'm wondering why that is. Is docker-machine the thing that runs natiely on windows, while Docker Engine doesn't? I think the word docker is over-loaded and maybe leads to confusion in this case :)

Thanks in advance!

like image 667
TigerBear Avatar asked Jan 14 '18 16:01

TigerBear


People also ask

Does Docker on Windows require Hyper-V?

Docker Desktop on Windows 10 supports two backends: HyperV and WSL2. WSL2 in turn also uses Hyper-V — so without having Hyper-V enabled Docker Desktop fails to start and can't be used.

Does Docker depend on Hyper-V?

When run linux container in windows10, in fact, it still needs a linux system as a docker host, because linux container cannot share kernel with windows. If enable hyper-v, docker-windows will auto setup a MobyLinuxVm in hyper-v as a virtual machine which act as the host machine of docker.

Can you run Docker containers natively on Windows?

Docker containers can only run natively on Windows Server 2016 and Windows 10. Other versions won't work with Docker because they lack the kernel enhancements necessary to support Docker containers, Scott Johnston, Docker COO, explained in an interview.

What does Hyper-V do in Docker?

Creates a Boot2Docker virtual machine locally on your Windows machine using Hyper-V. Hyper-V must be enabled on your desktop system. Docker for Windows automatically enables it upon install.

Can Docker desktop run on Hyper-V?

They can only run inside an Hyper-V based container. And because Docker Desktop supports to switch between Windows and Linux containers, it simply expects you to have Hyper-V installed, no matter what. Ok, but is that so bad after all? Well, maybe it is, maybe not.

Why can't I use a Windows container as a docker host?

Docker container had to share kernel with host, there are no linux kernel on windows, so for all situations, you had to have a virtual machine with linux as docker host, either hyper-v or virtualbox if no hyper-v support. In theory, windows container could share the kernel of windows, so no virtual machine needed.

What is Docker and how does it work?

By “native,” Docker means that the containers run using new primitives—the equivalent of namespaces in Linux—that are built into the Windows kernel itself. There’s no more virtualization. But that’s not all. The complete Docker tool set also now runs natively on Windows.

What is the difference between Docker containers and Linux containers?

Much of the confusion arises with Docker trying to support containerization on Windows. A container is considered “native”, if it can run directly on the host operating system. Linux Container: A Linux application that runs in an isolated Linux environment.


1 Answers

Docker support for Windows has several variants:

  1. Docker Toolbox which includes Docker Machine that will spin up a boot2docker image inside of VirtualBox. These are Linux containers running with a Linux kernel inside the VM. This was originally the only option for Windows users.

  2. Docker for Windows using Hyper-V to run the Moby VM, based on LinuxKit, to run Linux images. LinuxKit provides a container based Linux OS, and there's some integration to make it appear less like a VM to the end user, e.g. you can use 127.0.0.1 instead of the IP of the VirtualBox VM. If you have Hyper-V available and want to run Linux containers on Windows, this is the preferred option.

  3. Windows Server Containers which run Windows binaries on the same host OS, similar to how Linux containers on a Linux OS do not need a VM.

  4. Hyper-V Containers which run Windows binaries inside of a separate VM for additional isolation.

You can read more about the latter two options in Microsoft's docs.

What's important to note is that when you install Docker for Windows on a supported server, like 2016, you have options 2, 3, and 4, that you can toggle between. For Linux and Windows containers, there's a switch in the settings that affects all running containers and commands. And between Windows Server Containers and Hyper-V containers, there's an --isolation option on the docker run command line. So I believe you're required to have Hyper-V support to cover 2 and 4 even if you only want option 3.

like image 86
BMitch Avatar answered Oct 05 '22 07:10

BMitch