Deploy a Docker Container in Windows Server 2016

By | 03/04/2018

Windows Server 2016 includes native support for Docker-based containers. Here’s the way to install and deploy Windows Server-based containers.

A container image is a lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it: code, runtime, system tools, system libraries, settings. Available for both Linux and Windows based apps, containerized software will always run the same, regardless of the environment. Containers isolate software from its surroundings, for example differences between development and staging environments and help reduce conflicts between teams running different software on the same infrastructure.

Docker and stevedore-based containers are a giant deal within the free and open supply code (FOSS) house for a short while currently. during a shell, stevedore containers square measure virtualized applications that run in their own isolated memory house which have their own “sandboxed” classification system.

Let get started.

Open an administrative PowerShell console and install the new Containers feature:

Install-WindowsFeature -Name Containers -Restart


Let’s now create a folder to house the Docker program files:

New-Item -Type Directory -Path ‘C:\Program Files\Docker’ -Force


The following two Invoke-WebRequest calls download the Docker engine (daemon in UNIX language) and the Docker client from the Microsoft servers:

Install-Module -Name DockerMsftProvider -Repository PSGallery -Force

Invoke-WebRequest -Uri -OutFile $env:ProgramFilesDockerdocker.exe -UseBasicParsing


We should add the Docker directory to our system path so we can call the Docker client from wherever we are in the file system.

[Environment]::SetEnvironmentVariable(“Path”, $env:Path + “;C:\Program Files\Docker”, [EnvironmentVariableTarget]::Machine)


You’ll have to restart your administrative PowerShell console to put the environment variable change into effect.To wrap up installation, we’ll install the Docker daemon as a Windows service by calling on the dockerd executable directly:

dockerd –register-service

Start-Service Docker


Downloading the Base Images

In Docker container nomenclature, the image is the template from which you spawn new containers. We can download some per-built Docker images from the Microsoft servers by installing the container image package provider:

Install-PackageProvider ContainerImage -force


Deploy Your First Docker Container

Microsoft engineers actually figured out how to run the Windows Server operating system as a container.

To get a list of your Nano Server and Server Core images, run the following command:

Upload an Image to Docker

The -it switch denotes an interactive session, and cmd.exe means that we want to enter the container inside a new cmd.exe console.

Let’s upload the image we just created to Docker so that it’s accessible from the cloud. Log in using your Docker ID and password:

docker login


Create a New Image

We can now build a new image using the previously downloaded Windows Server (NanoServer) image as a starting point. Before starting, you’ll need a Docker ID. If you don’t already have one, sign up for a Docker account.

Docker images are usually created from Docker file recipes, but for the purposes of the demonstration, we’ll run a command on the image we downloaded, create a new image based on the change, and then upload it to Docker so that it’s accessible from the cloud.

docker pull microsoft/nanoserver


View images available in your repository in the Docker cloud..

Leave a Reply

Your email address will not be published. Required fields are marked *