Enable Hyper-V & Containers and Install Docker on Window Servers

Steps for enabling necessary features and installing necessary packages for deploying docker and containers on Windows Server 2016

Step 1: Install and Import Docker Package Provider

Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Install-Module DockerMSFTProvider
Import-Module -Name DockerMSFTProvider -Force
Import-Packageprovider -Name DockerMSFTProvider -Force

Use Find-Package to verify the new docker package is available:


PS C:\> Find-Package docker
################################
# Expected Output
################################
Name                           Version          Source           Summary
----                           -------          ------           -------
Docker                         18.09.5          DockerDefault    Contains Docker EE for use with Windows Server.
Docker                         1.3.2            PSGallery        This module helps with development using Doc...

Step 2 (VM Only) : Enable Nested Virtualization

Make sure the virtual machine is down.

For Windows-VM:

# Enable Nested Virtualization
Set-VMProcessor -VMName <VMName> -ExposeVirtualizationExtensions $true
# In order for network packets to be routed through two virtual switches
Get-VMNetworkAdapter -VMName <VMName> | Set-VMNetworkAdapter -MacAddressSpoofing On

For Xen-Server

Check if physical cpu has the flag vmx which stands for virtualization support enabled in BIOS for intel VT-x.

In the cfg file, add the following parameters:

nestedhvm=1 
hap=1

Restart the virtual machine.

Step 3: Enable Hyper-V and Container Windows Features

In PowerShell, run the following commands:

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

Restart the virtual machine.

Step 4: Install Docker

Install-Package -Name Docker -Source DockerDefault

Last updated

Was this helpful?