Create and run Hyper-V containers using Docker on Windows 10 desktop

As you probably know the Windows Insider program allows to get preview Windows 10 builds to test the new features that are coming in the next major update of Windows. Since a few weeks, a new feature named Container has been included in Windows 10 preview builds. This feature brings Hyper-V containers on the desktop, natively.

There are two different kind of containers on Windows : Windows Container and Hyper-V Container. They work in the same way, instead of that Hyper-V containers are more isolated than Windows Container because they are running in a very lightweight virtual machine that provides kernel isolation and not just process isolation.

For more information about Hyper-V containers, check the official documentation on MSDN: Hyper-V Containers

You want to try it? It’s pretty simple! First, you need to enroll your machine in the Windows Insider program (see link above) and get the latest build from the insider fast ring.

Once done, just open the Turn Windows features on or off, then select Containers and Hyper-V in the list:

Click image for larger version. 

Name:	docker-windows10-001_thumb.png 
Views:	2 
Size:	41.4 KB 
ID:	82647

Click OK to install the two components and restart your computer when the installation has completed.

Now, open a PowerShell console in administrator mode. The first thing to do is to change the execution policy to unrestricted using the following command:

Set-ExecutionPolicy Unrestricted

Then you can install the ContainerImage package provider:

Install-PackageProvider ContainerImage -Force

Click image for larger version. 

Name:	docker-windows10-003_thumb.png 
Views:	0 
Size:	42.8 KB 
ID:	82648

This package provider will allow you to pull the base operating system image to run Hyper-V containers. In this case, as you are going to run Hyper-V container you need to use the NanoServer base container image. To pull this image, you have to execute the following command:

Install-ContainerImage NanoServer

Depending on your Internet connection, this step can take a while…

Once the base container image is downloaded you can install Docker on your machine to be able to run and manage containers. To do that, you can download a PS script from and save it on your computer. Just run this script that will install all the stuff you need: the Docker client, the Docker deamon, all the configuration, environment variables…

Click image for larger version. 

Name:	docker-windows10-004_thumb.png 
Views:	0 
Size:	127.0 KB 
ID:	82649

You can now use the Docker commands to work with Hyper-V containers! For example getting the list of available images on your computer:

Click image for larger version. 

Name:	docker-windows10-005_thumb.png 
Views:	0 
Size:	45.8 KB 
ID:	82650

To be able to use this image without specifying its tag you can tag it as the latest image using the docker tag command:

Click image for larger version. 

Name:	docker-windows10-006_thumb.png 
Views:	0 
Size:	60.0 KB 
ID:	82651

Now you can switch to a CMD window, with administrator rights and create a new Hyper-V container use the following command:

docker run -it –isolation=hyperv nanoserver cmd

After a few seconds you will be running in an Hyper-V container!

Click image for larger version. 

Name:	docker-windows10-007_thumb.png 
Views:	0 
Size:	25.6 KB 
ID:	82652
You’re done Smile You can now run any Hyper-V container on your Windows 10 computer. Do you like it?

If you have any question about this post or running containers on Windows, feel free to contact me on Twitter @jcorioland