7th December 2016

 

In Windows Server 2016, which was released on Oct 12, 2016 Microsoft released the native windows support for Containers. It’s better to be late than never.

The installer for Docker for Windows can be found here https://download.docker.com/win/stable/InstallDocker.msi

You can start windows container either in Windows Server moder or Hyper-V mode. Images created in one can be used in other. The difference between these two modes is the level of isolation when launching the image.

One of the great things about Docker for Windows is you don’t have to relearn how to work with containers if you have past experience with Linux container. However there are a number of functionalities of docker in Linux, that is not being implemented in its windows port.

The source code for Docker can be found in https://github.com/docker/docker

The way the interfaces are implemented in Go, make it very easy for the core development team to write windows & linux specific implementation while keeping the user interface (the commands line) the same.

Both of windows and linux specific implementation can be found in the same repository. To find out a specific implementation of either Linux or Windows, just do a search with “// +build !windows” this is the build tag to indicate to go compiler to only include this file if the build system is not windows.

So if you browse on the repo, you normally see a lot of files with the postfix of either _windows or _linux, all _linux files have the postfixed mentioned above, which means when they’re compiled for docker linux distro and not for windows.

If you compare the two files, you notice that there are a lot of methods in files with windows postfix that is not implemented, .e.g

A. container_windows.go

screen-shot-2016-11-25-at-16-49-59

B. daemon_windows.go

screen-shot-2016-12-08-at-12-33-19

 

This will give you some idea of what functions are not implemented in windows, such as getSystemCPUUsage in stats_collector_windows.go

screen-shot-2016-12-08-at-12-35-15

You can also search for runtime.GOOS == “windows” to know which specific feature is implemented or not implemented on windows. Feature such as diff on running container, which is not supported in Windows.

screen-shot-2016-12-08-at-12-36-07

So when a particular feature does not on Windows Docker engine, consult the source code to check whether that feature is in fact implemented or not.

Windows’ equivalence of LXC

Docker for Windows uses hcsshim (https://github.com/Microsoft/hcsshim) package to create containers in Windows Servers. The hcsshim library itself is a go package that serves as a wrapper to windows system dll called vmcompute.dll

This system library itself is the OS primitive that does the virtualization for you.

screen-shot-2016-12-08-at-12-37-30

Docker command line is not the only way for you to interact with the docker daemon (docker windows service in Windows world). There is a PowerShell cmdlet (https://github.com/Microsoft/Docker-PowerShell) that you can use if you’re more familiar with powershell or want to integrate your existing powershell script with dockers.

This powershell cmdlet itself is built on top of Docker.DotNet (https://github.com/Microsoft/Docker.DotNet). Docker.DotNet itself is just a library that interact with the Docker Remote API(https://docs.docker.com/engine/reference/api/docker_remote_api/).

 

About William Sia


No Comments

Leave a comment