Let's get started with Windows Containers!!!

If you want to dockerize or run your application in docker then you need to first choose the right version of windows container as Windows is strict about version compatibility.

Before choosing Windows Container images make sure that you meet the Host OS requirements.

Choosing the Host Operating System:

The Windows container feature is only available on the following Operating Systems

  1. Windows Server 2016 (Core and with Desktop Experience)
  2. Windows 10 Professional and Enterprise (Anniversary Edition) and later.
  3. And the latest OS with long term support Windows Server 2019.

Note: On Windows 10 Pro and Enterprise you can run only in Hyper-V isolation configuration without any difference in Dockerfile but just some extra load on your system for virtualization.

Now that we have picked one operating system from above as host operating system, It's time to pick the base image to build your application.

Choosing Base Images:

Microsoft offers the 4 base images currently.

  1. Windows Server Core: If the application you want to build depends on the full .NET framework, then this image is suitable one.
  2. Nano Server: As the name suggests this image is trimmed version of Windows Server Core, you can pick this image if your applications require only .NET Core.
  3. Windows: If you application is not running as expected in the Windows Server Core and Windows Nano Server or  require additional components then you may pick this image as it carries the full dependency set of Windows OS.
  4. IoT Core: This image is for IoT applications. You can use image only on IoT Core Host

Refer this image for more info

docs.microsoft.com

Choosing the Right Version of Base Image / Container OS version

Here comes the trick part with Windows Containers. Microsoft strict with version compatability with base image / Container OS version and the host OS.

Because Windows Server containers and the host operating system share same kernel, therefore the Windows container’s base image must match to that of the host operating system. If the versions are different, the container may start, but full functionally isn't guaranteed.

To choose right version of container. Open your docker terminal and get your Host Operating System version number by entering the following command

docker info

When you enter the above command you can find the build number, kernel version and along with other bunch of info about your host operating system.

Once you got the version number. You need to use it as a tag to pull the windows container.

In my case the version is 1803, So the docker command will look like this

docker pull mcr.microsoft.com/windows/servercore:1803

Please note that Microsoft repo does not publish or maintain a latest tag, So if you enter wrong tag you may get the following error.

You can also get specific version of container check here for more info

no matching manifest for unknown in the manifest list entries

Run Windows Containers

Now that you have got the right version of windows containers on your machine. It's time to run the container.

To run the container all you need to do is open your docker terminal and enter the following commands

docker images

From above command you will get the list of images with tag id. Note down the tag id and attach at the ending of repo url like

docker run -it mcr.microsoft.com/windows/servercore:1803

That's it now wait for few seconds to spin the windows docker container. And you will be in the container's command prompt.

If  you want to copy your can application files, then you can stop the docker container and copy the files and start again.