windows-docker introduction

background:

The news of supporting docker on windows is not unfamiliar. But to what extent is it now?
On a whim, I started looking for ways to use docker on windows.

part 1 docker for windows officially given by docker

Getting Started with Docker for Windows describes how to use docker on windows.
First of all, the environment requires 64bit Windows 10 Pro, and then the HyperV service needs to be enabled.
Then download the installation package.
The installation process is still quite smooth. The next step along the way is OK.
Then you can start to experience the container service under our windows.

The official example uses the ubuntu image.
A big question here comes to mind, can the Windows Container Service already run Linux container images directly?
With curiosity, started the ubuntu mirror.

docker run -it ubuntu bash

Entering the mirror can't help but want to see what is going on. uname -a to check the kernel version.
The kernel of 4.4.5 appeared in front of us. Is it true that the container running on windows is just running in a virtual machine.

Open the HyperV manager, you can see that a virtual machine is indeed started.
The virtual machine uses the MobyLinuxVM.vhdx file as a data disk to store the docker image file. mobylinux.iso as the startup disk
to load the linux system.

Ok. The principle is clear. The HyperV virtual machine was used to run a customized version of Linux,
and then Windows installed Docker to communicate with this customized version of Linux to achieve the purpose of using the container. The image used is the image of linux.

The principle is clear, but there are some inexplicable disappointments, is the container on Windows used this way? What about native Windows programs?

use

docker search microsoft

Some surprise discovery

NAME                                          DESCRIPTION                                     STARS     OFFICIAL   AUTOM
ATED
microsoft/aspnet                              ASP.NET is an open source server-side Web ...   464                  [OK]
microsoft/dotnet                              Official images for working with .NET Core...   207                  [OK]
mono                                          Mono is an open source implementation of M...   172       [OK]
microsoft/azure-cli                           Docker image for Microsoft Azure Command L...   61                   [OK]
microsoft/iis                                 Internet Information Services (IIS) instal...   25
microsoft/mssql-server-2014-express-windows   Microsoft SQL Server 2014 Express installe...   23
microsoft/nanoserver                          Nano Server base OS image for Windows cont...   11
microsoft/windowsservercore                   Windows Server Core base OS image for Wind...   8
microsoft/dotnet-preview                      Preview bits for microsoft/dotnet image         5                    [OK]
microsoft/oms                                 Monitor your containers using the Operatio...   5                    [OK]
microsoft/applicationinsights                 Application Insights for Docker helps you ...   3                    [OK]
microsoft/sample-nginx                        Nginx installed in Windows Server Core and...   2
microsoft/sample-node                         Node installed in a Nano Server based cont...   2
microsoft/sample-redis                        Redis installed in Windows Server Core and...   2
microsoft/dotnet35                                                                            2
microsoft/sqlite                              SQLite installed in a Windows Server Core ...   1
microsoft/sample-httpd                        Apache httpd installed in Windows Server C...   1
microsoft/sample-mongodb                                                                      1
microsoft/sample-mysql                        MySQL installed in Windows Server Core and...   1
microsoft/sample-dotnet                       .NET Core running in a Nano Server container    1
microsoft/sample-golang                       Go Programming Language installed in Windo...   0
microsoft/sample-python                       Python installed in Windows Server Core an...   0
microsoft/sample-ruby                         Ruby installed in a Windows Server Core ba...   0
microsoft/dotnet-nightly                      Preview bits of the .NET Core CLI               0                    [OK]
microsoft/sample-rails                        Ruby on Rails installed in Windows Server ...   0

Already have a Microsoft image, so try to download a Microsoft / IIS image. In execution

docker run -it microsoft/iis cmd

But an error is reported. Prompt to find $ PATH variable.

At this point, it can basically be determined that this windows image is not used in this way. So how to use the container service on windows?

part 2

You can see it in a glance after the peak loop, and there is a special introduction on the Windows docker service on the MSDN website.

According to the docker installation prompt on windows , you can really experience the container service of windows.

First of all, as of now, the container service of windows has not been officially released yet. But as a developer, you can start some work.

The environment requires a preview version of Windows 10, which needs to be updated to a developer version in win10.
Then install as described in the article to start the container normally.

Here to talk about, pay attention to:

  • The docker downloaded from the English version introduced by windows docker is version 1.2.0. There are bugs in this version and errors will occur on windows.
    The Chinese version introduction page can be used normally by downloading 1.3.0 directly.
  • The windows container needs to start the HyperV service.
  • There are two kinds of containers in windows, one is on windows, and this is used in win2016server version. One is with the help of HyperV, the one used in win10 is with the help of HyperV
  • The container used in win10 uses the image of nanoserver, which is a miniature version of windows. The win2016server directly uses the windowsservercore image.
  • In the container of win10, actually use HyperV's virtual machine to start the nanoserver image, and then run the windows program in the image. Each docker container is a virtual machine.
  • According to the documentation, the container started in winserver should be similar to the Linux container, and the kernel of the host machine is really shared.

summary:

As can be seen from the container service provided by windows, the essence of docker should actually be image + resource isolation. It is not so closely related to using containers or virtual machines themselves.
Under windows, in order to be able to start the Linux program, you still need to use a virtual machine to do operating system isolation. The windows itself also has a personal version and a server version.
Due to the different kernel forms of the two versions, Windows has also adopted a virtual machine to start a miniature kernel in order to allow the personal version to use the container service.
This idea may be used on Linux. Start the virtual machine of nanoserver on Linux, and then run the windows program. From this point of view, to abandon the vessel itself brings performance
advantages, it is encapsulated in a virtual machine to provide the level of service such that the container service real operating system independent. And this also has far-reaching significance for the containerized transformation of a large number of windows services in enterprises.

Published 6 original articles · Likes0 · Visitors 10,000+

Guess you like

Origin blog.csdn.net/ssdxiao0/article/details/52221254