×
Running HYPER-V Containers in Windows 2016
Containers Uncategorized

Running HYPER-V Containers in Windows 2016

Hyper-V container in windows 2016

In this blog, we show you how to create a hyper-V container windows 2016.

 

REQUIREMENTS

  • Need to install Hyper-V role on the server.

Note : We are using the nested VM for this demonstration purpose.

 

CONFIGURE THE NESTED VM

Please follow the below blog to configure the nested virtualization for a VM.

https://www.assistanz.com/nested-virtualization-windows-2016/

 

INSTALLING HYPER-V ROLE

 

  • Click on start menu and select server manager.

hyper-V container windows 2016

 

  • Click on Add roles and features option.

hyper-V container windows 2016

 

  • From the welcome screen, Click Next.

hyper-V container windows 2016

 

  • Need to select Role-based or feature-based installation option and click Next.

hyper-V container windows 2016

 

  • Select the server and click Next.

hyper-V container windows 2016

 

  • Select the Hyper-V role and click Next.

hyper-V container windows 2016

 

  • Don’t select any components in this screen. Click Next.

hyper-V container windows 2016

 

  • Select the network adapter for Hyper-V VM’s and click Next.

hyper-V container windows 2016

 

  • We can configure the virtual machine migration later. Click Next.

hyper-V container windows 2016

 

  • Specify the default store for VM files. Click Next.

hyper-V container windows 2016

 

  • Click Install button to install the Hyper-V Role on the server.

hyper-V container windows 2016

SERVER REBOOT

  • Restart the server to complete the installation.

hyper-V container windows 2016

 

CREATING WINDOWS CONTAINER IN DETACH MODE

  • To create a windows container in detach mode, type the following command.

Syntax: docker run -d –name <name for the container> <container image name> <executing the command>

Example: docker run -d –name srv01 microsoft/nanoserver ping 127.0.0.1

hyper-V container windows 2016

 

 

CREATING HYPER-V CONTAINER IN DETACH MODE

  • To create hyper-V container, type the following command.

Syntax: docker run -d –name <name for the container> –isolation=hyperv <container image name> <executing the command>

Example: docker run -d –name srv02  –isolation=hyperv microsoft/nanoserver ping 127.0.0.1 -t

hyper-V container windows 2016

 

Note: It will take little bit of extra time while creating hyper-V containers when comparing to windows containers

 

DIFFERENCE BETWEEN WINDOWS CONTAINER AND HYPER-V CONTAINER

Windows containers are sharing the container host kernel. Hyper-V containers are having their own kernel as its own virtual machine. If we run docker ps we can see both the containers and there is no difference in it.

 

hyper-V container windows 2016

 

INSPECTING THE WINDOWS CONTAINER

  • Run the below command to inspect the first container srv01.

docker inspect srv01

 

hyper-V container windows 2016

 

It displays the JSON data related to srv01 container. In that data, we can find the isolation type for this container.

hyper-V container windows 2016

This was created as windows container using process isolation method.  This container is sharing the kernel with the host operating system.

 

INSPECTING THE HYPER-V CONTAINER

 

  • Run the below command to inspect the second container srv02

docker inspect srv02

 

It displays the JSON data related to srv02 container. In that data, we can find the isolation type for this container.

 

hyper-V container windows 2016

 

It created as Hyper-V container so it’s using its own kernel inside the virtual machine.  It will create virtual machine internally for this container and we will not see it in the hyper-V console.

hyper-V container windows 2016

 

FORMATTING INSPECT COMMAND

We can filter the data from the JSON file using –f option in the docker command.

  • To filter the isolation type for a container, type the below command.

Syntax: docker inspect -f “{{.HostConfig.Isolation}}” <container name> or <container ID>

Example: docker inspect -f “{{.HostConfig.Isolation}}” srv01

 

hyper-V container windows 2016

 

VIDEO

 

Thanks for reading this blog. We hope it was useful for you to learn how to create hyper-V container in windows 2016.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.