Server NewsWindows Server 2016 Containers Docker

Windows Server 2016 Containers Docker

ServerWatch content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

Microsoft’s latest server operating system signals a whole new way of thinking for Microsoft, highlighted by the incorporation of open source projects like Docker via Windows Server Containers and Hyper-V Containers.

With the release of Windows Server 2016, Microsoft has introduced a wide range of new features and capabilities, including tight integration with Docker containers. Windows Server 2016 ContainersClose collaboration with Docker resulted in the open source tool being featured in the final version of Windows Server 2016 after debuting in an initial technical preview release in TP3.

You actually get two options in Windows Server 2016: Windows Server Containers and Hyper-V containers. A Hyper-V container is based on a stripped-down virtual machine running Windows Server that has one purpose, which is to serve as a host for a container. This method has additional shielding or isolation from the host operating system, as there is no sharing of the host Windows kernel.

A Windows Server container functions in essentially the same manner as a Linux container by sharing the host kernel across all running containers.

The one thing you don’t get at the present is the ability to run Linux containers on Windows Server. It is possible on Windows 10 if you install Docker from the beta development tree.

Running Docker for Windows on Windows 10 requires 64-bit Windows 10 Pro, Enterprise or Education editions version 1511 or later. With one of these editions installed you get a handy icon in the Windows tray with a menu item to switch between Linux and Windows containers.

Installation and Configuration

Using PowerShell is the quickest way to get Docker installed and running. Three commands will install and reboot the system, resulting in a Docker-capable system. Here’s what the PowerShell looks like:

Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
Install-Package -Name docker -ProviderName DockerMsftProvider
Restart-Computer -Force

If you want to run Hyper-V based containers you will need to run a few more commands to make that work.

First, the Hyper-V role must be installed as it does not come loaded by default. This can be accomplished with the following PowerShell command:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

You will also need a virtual switch which can be done with these PowerShell commands:

Get-NetAdapter | ? Virtual -eq $false
$net = Get-NetAdapter -Name 'Ethernet'
New-VMSwitch -Name "External" -AllowManagementOS $True -NetAdapterName $net.Name

The first command will display a list of physical adapters, and typically contains at least one named Ethernet if you have a wired connection.

On the next line we assign the output of the Get-NetAdapter command to the variable $net and then use that to create a new VMSwitch. With this step complete you will need to reboot the system once more for the changes to take effect.

Launching and Managing Containers

With the basic Docker infrastructure installed you can launch a new container from PowerShell with a command like one of the following:

docker run microsoft/dotnet-samples:dotnetapp-nanoserver
docker run -it -p 80:80 microsoft/iis cmd

Both of these commands will download an image from the Microsoft repository if you don’t have it available locally. The command docker pull imagename will download an image where imagename is any one of the available images from the Microsoft repository available on docker hub. As of this writing you’ll find 38 images with a wide variety of capabilities from base OS to SQL server and more.

The Docker docs site has a good article entitled “Get started with Docker for Windows” with everything you need to know about running Docker on Windows 10 in a step-by-step tutorial.

Windows Server 2016 - Containers

Docker command-line tools are consistent across platforms, which is one reason Docker has become so popular among developers. The command docker images (see Figure 1) will return a list of all installed images on all platforms with the associated image ID and size.

Windows Server 2016 - Containers

Typing the command docker psreturns a list of all running containers along with the base image name and a container ID (see Figure 2). This ID can be used in other commands to get more information such as getting the IP address of the container. The following command will return the IP address of the container with the ID fa335c2a6527:

docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' fa335c2a6527

One other concept you will want to learn more about is the Dockerfile. Dockerfiles make it possible to automate the process of creating Docker images in a repeatable fashion. This becomes especially important in a development environment with multiple images containing different functional pieces of a larger application.

For Windows containers you’ll want to read the Microsoft documentation on building a Dockerfile specifically for the Windows environment.

This will differ from Linux images in that it will use Windows commands like DISM to install specific features. The good news here is the availability of many examples on github for you to peruse at your leisure.

Wrap Up

Microsoft has fully embraced the open source nature of Docker with collaboration happening on github and documentation available for public comment and contribution. Windows Server 2016 represents a whole new way of thinking for Microsoft with the incorporation of open source projects like Docker available as optional features installed as a part of the operating system.

Look for more open source integration and further development of the Docker platform on Windows in the months to come.

Paul Ferrill, based in Chelsea, Alabama, has been writing about computers and software for almost 20 years. He has programmed in more languages than he cares to count, but now leans toward Visual Basic and C#.

Follow ServerWatch on Twitter and on Facebook

Get the Free Newsletter!

Subscribe to Daily Tech Insider for top news, trends & analysis

Latest Posts

Related Stories