TensorWorks Training Logo

CN001 - Containers and container orchestration

Activity 4: Running Hyper-V isolated Windows containers

Contents

What you’ll need

To build and run Windows containers in Hyper-V isolation mode, you’ll need one of the following system configurations:

Using Hyper-V isolation mode

Pull the Windows Server 2016 version of the Windows Server Core base image:

docker pull "mcr.microsoft.com/windows/servercore:ltsc2016"

If you attempt to run a container with this older image in process isolation mode under a newer host OS then you will receive an error message informing you of the kernel version incompatibility:

# This will produce an error message similar to the following:
# "The container operating system does not match the host operating system."
docker run --rm -ti --isolation=process "mcr.microsoft.com/windows/servercore:ltsc2016" cmd

In order to run the container under a newer host OS, you will need to use Hyper-V isolation mode instead:

# Start a Windows Server 2016 container using Hyper-V isolation mode
docker run --rm -ti --isolation=hyperv "mcr.microsoft.com/windows/servercore:ltsc2016" cmd

You may notice that the container takes perceivably longer to start than containers running in process isolation mode. You can verify that the container is running an older kernel inside a Hyper-V utility VM by inspecting the system information:

# Query the OS version of the container
systeminfo | findstr /B /C:"OS Version"

You should see the version string for Windows Server 2016 (OS Version: 10.0.14393 N/A Build 14393) printed. You can also query the system information to observe the default memory limit imposed on Hyper-V isolated containers, which is 1GiB:

# Query the quantity of memory available to the container
systeminfo | findstr /B /C:"Total Physical Memory"

You should see the output 1,023 MB listed. If you stop the container then you can start a new container with a higher memory limit:

# Start a container with a 2GB memory limit
docker run --rm -ti --isolation=hyperv -m 2GB "mcr.microsoft.com/windows/servercore:ltsc2016" cmd

If you run the previous memory query command inside the new container you should see the output 2,559 MB listed.