Advance

How to Run Linux Containers on Windows Server 2019

How to Run Linux Containers on Windows Server 2019

[Updated] Docker on Windows only runs Windows containers. To use Linux containers on Windows Server, you need to use the Docker Enterprise Edition Preview which includes a complete LinuxKit system for running Docker Linux containers. This article will teach you How to Run Linux Containers on Windows Server 2019. You can choose your perfect Windows VPS Server Packages from the Eldernode website.

Why you should use Linux containers on Windows Server 2019

Recommended Article: Tutorial Clear Local DNS Cache

What is Docker EE?

Docker EE stands for Docker Enterprise Edition and is designed for enterprise development. It makes it easy to build, ship, and run business-critical applications with their dependencies and avoid crazy dependency issues common with the use of Virtual Machines. This technology is an integrated, supported, and certified container platform for CentOS, Microsoft Windows servers, and Oracle Linux. Also, Docker EE supports both AWS and Microsoft Azure cloud providers.

Install Docker on Windows Server 2019

In this section, we will explain how to run Linux containers on Windows Server 2019. To do this follow the steps below and enter the required commands.

First, you should enable the Windows Server 2019 containers feature. To do this, go to the Windows server> Windows Powershell and open PowerShell as an administrator:

 

Run-PowerShell-as-Administrator

 

And install the Docker-Microsoft package management provider from the PowerShell Gallery using the following command:

Install-Module -Name DockerMsftProvider -Repository PSGallery -Force

After you enabled Containers, you can install the Docker Engine and Client with the command below:

Install-Package -Name docker -ProviderName DockerMsftProvider

Once the installation is completed, reboot the computer using the following command:

Restart-Computer -Force

You can check the Docker version with the command below:

Get-Package -Name Docker -ProviderName DockerMsftProvider

or

docker version

How to Create a Container Registry

Once installed, you will need to configure the server to allow access to the Docker Hub.

Now follow the steps below to create a container registry:

–> Choose the project you want to create a registry on the navigation bar.

–> Choose Packages> New Repository on the project sidebar menu.

–> Specify repository settings such as choosing Container Registry, specifying the registry name and description, choosing the type of Access, and Selecting immutable tag names and immutable images.

–> Click on Get Started to see the command-line snippets.

How to Deploy and Manage Containers using PowerShell

First, start the Docker daemon by entering the following command:

start-service docker

And download the pre-created .NET sample image from the Docker Hub registry using the command below:

docker pull mcr.microsoft.com/dotnet/samples:dotnetapp-nanoserver-2009

Finally, you need to deploy a simple container running a .NET Hello World application by running the command below:

docker run mcr.microsoft.com/dotnet/samples:dotnetapp-nanoserver-2009

Congratulations the container will start and print the hello world message.

Install Docker on Windows Server 2019

Before doing anything you should uninstall your current Docker CE with the following command:

Uninstall-Package -Name docker -ProviderName DockerMSFTProvider

If you are using a Linux Virtual Machine running on Hyper-V, enter the following command to enable Nested Virtualization:

Get-VM WinContainerHost | Set-VMProcessor -ExposeVirtualizationExtensions $true

Now it’s time to install the preview Docker EE build. To do this, run the following command:

Install-Module DockerProvider  Install-Package Docker -ProviderName DockerProvider -RequiredVersion preview

Then you need to enable LinuxKit for running Linux containers with the command below:

[Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", "1", "Machine")

Finally restart Docker Service using the following command:

Restart-Service docker

You can pull a test docker image using the command below:

docker run -it --rm ubuntu /bin/bash

If you want to switch back to running Windows containers, enter the command below:

[Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", "$null", "Machine")

That’s it!

Conclusion

Docker EE for the windows server enables native docker containers on the Windows server. In this article, we taught you how to run Linux Containers on Windows Server 2019. We hope you enjoyed this tutorial, you can ask questions about this training in the comments section.

We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

2 thoughts on “How to Run Linux Containers on Windows Server 2019

Leave a Reply

Your email address will not be published. Required fields are marked *

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day