Установка docker на windows server 2019

В нашем справочнике есть мануал по установке Docker на сервере, работающем под управлением Ubuntu 20.04. Настоящая же статья посвящена тому, как запустить хранилище Docker на операционной системе Windows Server 2019.

На виртуальном сервере, работающем под управлением Windows Server 2019, производить установку Docker наиболее оптимально при помощи интегрированной среды PowerShell. Запустить PowerShell можно из командной строки, используя команду powershell, либо из оболочки Server Manager – ToolsWindows PowerShell.

Установка Docker

Первым шагом необходимо будет установить функцию контейнеров. Сделать это можно при помощи следующей команды:

Install-Module -Name DockerMsftProvider -Repository PSGallery -Force

Далее нужно установить сам Docker, для чего используйте следующую инструкцию:

Install-Package -Name docker -ProviderName DockerMsftProvider

Во время инсталляции система попросит вашего согласия на установку пакета. Для продолжения установки нужно нажать Y.

Установка Docker

Следующей командой необходимо перезагрузить сервер по окончании установки Docker:

Restart-Computer -Force

Проверить версию установленного пакета можно при помощи команды:

Get-Package -Name Docker -ProviderName DockerMsftProvider
Версия Docker

Для этого также можно использовать следующую команду:

docker version
Версия Docker - Установка Docker на Windows Server 2019

Теперь необходимо запустить Docker:

Start-Service Docker

Запуск контейнера

После чего уже можно будет загрузить и установить базовый образ контейнера. Например, следующей командой вы сможете произвести загрузку базового образа Nano Server для Windows Server 2019:

docker pull mcr.microsoft.com/windows/nanoserver:ltsc2019
Загрузка образа mcr.microsoft.com/windows/nanoserver:ltsc2019

Список установленных образов можно вывести при помощи команды:

docker images
Список установленных образов - Установка Docker на Windows Server 2019

Теперь можно приступить к созданию образа. Команды, при помощи которых создаются и запускаются образы, лучше выполнять в командной строке, запущенной от имени администратора. Использование интегрированной среды Windows PowerShell не позволяет работать с контейнерами, так как контейнеры в конечном итоге перестают отвечать на запросы.

Запуск загруженного контейнера Nano Server с интерактивным сеансом производится следующей командой:

docker run -it mcr.microsoft.com/windows/nanoserver:ltsc2019 cmd.exe

В качестве примера на диске C:\ запущенного контейнера создайте каталог TEMP:

mkdir C:\TEMP

Перейдите в созданный каталог и создайте файл my_file.txt, содержащий текст My File:

cd C:\TEMP
echo "My File" > my_file.txt

После чего выйдите из контейнера:

exit

Следующая команда нужна будет для получения идентификатора контейнера, из которого вы только что вышли:

docker ps -a
Получение идентификатора контейнера

В нашем примере идентификатор контейнера выглядит как 722200a246df. Исходя из этого вы можете создать новый образ, в котором будут учитываться изменения, внесённые в изначальный образ. Для этого нужно будет использовать команду docker commit. Новый образ мы назовём my_container, поэтому команда для его создания будет выглядеть следующим образом:

docker commit 722200a246df my_container

При помощи команды docker images можно вывести список образов, в котором будет присутствовать новый образ:

Список образов

Теперь вы можете запустить созданный контейнер при помощи команды docker run. Использование параметра --rm позволяет удалить запущенный контейнер после завершения работы оболочки командной строки. В нашем примере мы запустим контейнер my_container и выведем содержимое файла my_file.txt из директории TEMP на диске C:\.

docker run --rm my_container cmd.exe /s /c type C:\TEMP\my_file.txt
Запуск контейнера - Установка Docker на Windows Server 2019

В итоге Docker создаст контейнер из образа my_container, запустит экземпляр командной строки, в которой выведет содержимое файла C:\TEMP\my_file.txt, после чего Docker остановит работу контейнера и удалит его.

How to Install and Run Docker on Windows Server 2016, 2019, 2022. In this tutorial we will introduce Docker and how it works with it’s main advantages then move onto installation phase with how to install Docker using PowerShell.

Docker is one of the most widely used containerization platform used by developers. It allows developers to create, deploy, and run applications with the help of containers.

Next in this article How to Install and Run Docker on Windows Server 2016, 2019, 2022 is to introduce Docker.

What Is Docker?

install and Run Docker on Windows Server 2016, 2019, 2022.

The Docker is an open source platform that allows you to build, deploy, run, update, and manage containers. They are standardized, executable components that integrate application source code with operating system libraries and dependencies they need to run that code in any environment.

With the help of containers, the process of simplifying the development and delivery of distributed applications becomes effortless. The platform is highly popular among organizations transforming themselves to cloud native developments and hybrid multi cloud environments. Therefore, by using Docker, you will tend to acquire the following additional advantages:

Docker Benefits

  • Light Weight – The Docker containers do not have to carry the payload of an entire OS instance and hypervisor. They only require the OS processes and dependencies for executing the code. Also, since their sizes are measured in megabytes, you can make better use of hardware capacity and have faster start-up times.
  • Greater Resource Efficiency – With the help of Docker containers, you can run several copies of the same application on the hardware as many times as you want, thereby reducing cloud spending.
  • Improved Developer Productivity – Write and run only once a time a containerized application anywhere. In comparison to VMs, they will run faster and deploy, provision and restart effortlessly. This way, you can make them ideal for usage in continuous integration and continuous delivery (CI/CD) pipelines. It will also be a better fit for development teams adopting Agile and DevOps practices.
  • Improved And Seamless Container Portability – Docker containers tend to run without modification across any desktop, data center, and cloud environment.
  • Automated Container Creation – Docker tends to build a container automatically according to the application source code.
  • Shared Container Libraries – Docker enables you to access open source libraries, which include numerous user contributed containers.
  • Containers Reuse – In Docker, you can use existing containers as base images, especially templates for building new containers.
  • Container Versioning – Docker trackers the versions of a computer image, get back to previous versions and then identify who built it and when. They also upload only deltas between an existing version and a new one.

Moreover, if you use containers, you tend to acquire benefits, like improved app quality, faster response to market changes, etc.

How Does Docker Work?

how docker works

Docker work by packaging, provisioning, and running containers. Its technology is available to the operating system. A container packages the application service or function will every library, configuration files, dependencies, and other necessary parts and parameters to operate. Every container contributes to the service of one underlying operating system.

Moreover, Docker images constitute the dependencies required for executing code inside a container. This way, containers that move between Docker environments with similar OS work with no changes.

Docker also uses resource isolation in the OS Kernel to run several containers on the same OS. It is not as same as Virtual Machines (VMs) that encapsulate an entire OS with executable codes on an abstracted layer of physical hardware resources.

On the other hand, Docker was developed to work on the Linux platform. However, it has extended its offer to provide support to non Linux Operating systems too. It includes Microsoft Windows and Apple OS X. Docker also has the version for Amazon Web Services (AWS) and Microsoft Azure.

Next in this post we will show you how to install and run Docker on Windows server 2016 / 2019 and 2022.

Enable the Containers Feature

By default, the container features are not enabled on Windows server machine. So you will need to enable it first.

				
					Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
				
			

The above command will install the Docker-Microsoft PackageManagement Provider from the PowerShell Gallery. 

Run Docker Engine on Windows in Azure

Run Docker Engine on Windows in AWS

Run Docker Engine on Windows in GCP

Install Docker Engine

After the Containers feature is enabled on Windows Server, open your powershell windows and install the latest Docker Engine and Client by running the command below:

				
					Install-Package -Name docker -ProviderName DockerMsftProvider
				
			

Once the Docker is installed, you will get the following output:

				
					WARNING: A restart is required to enable the containers feature. Please restart your machine.

Name                           Version          Source           Summary                                             
----                           -------          ------           -------                                             
Docker                         20.10.9          DockerDefault    Contains Docker EE for use with Windows Server. 

				
			

Next, you will need to restart your system to enable the docker features. You can run the following command to restart the system:

Verify the Docker Installation

You can verify the installed version of  Docker using the following command in the powershell window:

				
					Get-Package -Name Docker -ProviderName DockerMsftProvider
				
			

You will get the following output:

				
					Name                           Version          Source                           ProviderName                        
----                           -------          ------                           ------------                        
docker                         20.10.9          DockerDefault                    DockerMsftProvider                  
				
			

You can also run the following command to see the Docker version information:

You should see the Docker version information in the following output:

				
					Client: Mirantis Container Runtime
 Version:           20.10.9
 API version:       1.41
 Go version:        go1.16.12m2
 Git commit:        591094d
 Built:             12/21/2021 21:34:30
 OS/Arch:           windows/amd64
 Context:           default
 Experimental:      true

Server: Mirantis Container Runtime
 Engine:
  Version:          20.10.9
  API version:      1.41 (minimum version 1.24)
  Go version:       go1.16.12m2
  Git commit:       9b96ce992b
  Built:            12/21/2021 21:33:06
  OS/Arch:          windows/amd64
  Experimental:     false

				
			

If you want to get detailed information of Docker package, run the following command:

You should see the following output:

				
					Client:
 Debug Mode: false
 Plugins:
  cluster: Manage Docker clusters (Docker Inc., v1.1.0-8c33de7)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 19.03.2
 Storage Driver: windowsfilter
  Windows: 
 Logging Driver: json-file
 Plugins:
  Volume: local
  Network: ics l2bridge l2tunnel nat null overlay transparent
  Log: awslogs etwlogs fluentd gcplogs gelf json-file local logentries splunk syslog
 Swarm: inactive
 Default Isolation: process
 Kernel Version: 10.0 14393 (14393.3808.amd64fre.rs1_release.200707-2105)
 Operating System: Windows Server 2016 Standard Version 1607 (OS Build 14393.3808)
 OSType: windows
 Architecture: x86_64
 CPUs: 2
 Total Memory: 3.999GiB
 Name: CLOUD-0Q59R832Q
 ID: BTXL:3ZPL:A7MZ:FNCV:UZRU:VG7I:YU7X:DERR:2Q2Y:2YNL:SYGN:AGYT
 Docker Root Dir: C:\ProgramData\docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

				
			

Run the Docker Container

Next, download the Docker dotnet nano server container image using the following command:

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

Once the image is downloaded, you can run the container from the downloaded image using the following command:

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

Run Linux Container on Windows

By default, Docker on Windows machine can only run Windows container. In order to use Linux containers on Windows Server, you need to use the Docker Enterprise Edition Preview which includes a full LinuxKit system for running Docker Linux containers.

The first thins is to remove your Windows Docker engine using the following command:

				
					Uninstall-Package -Name docker -ProviderName DockerMSFTProvider
				
			

Secondly,  install Docker for Linux by running the following command:

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

Thirdly, enable LinuxKit system for running Linux containers using the following command:

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

The next step is to  start the Docker service with the following command:

Then download and run your first Linux container using the following command:

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

This command will download the latest Ubuntu container image, create the container and connect to the container shell as shown below: 

You can now run the following command inside the container to verify the Ubuntu version:

				
					root@21340a2fsf7e2:/# cat /etc/os-release 
 NAME="Ubuntu"
 VERSION="22.04.1 LTS (Jammy Jellyfish )"
 ID=ubuntu
 ID_LIKE=debian
 PRETTY_NAME="Ubuntu 22.04.1 LTS"
 VERSION_ID="22.04"
 HOME_URL="https://www.ubuntu.com/"
 SUPPORT_URL="https://help.ubuntu.com/"
 BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
 PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
 VERSION_CODENAME=Jammy Jellyfish
 UBUNTU_CODENAME=Jammy Jellyfish
				
			

To disconnect from the container, run the following command:

				
					root@21340a2fsf7e2:/# exit
				
			

How to Use Docker

Docker provides many useful commands that help developers or system administrators to easily manage Docker containers from the command line.

You can use the –name option with Docker to assign a container name when running a new container. For example, to launch a new container from the debian:latest images and assigned a name debian-container, run the following command:

				
					docker.exe container run --name debian-container debian:latest
				
			

After starting the container, you can see the status of all container using the following command:

There are two ways of running a container, in attached mode and in detached mode. By default, Docker runs the container in attached mode. In the attached mode, you will be connected to the terminal session, where it displays output and messages.

If you want to run a container in detached mode, use the -d flag:

				
					docker.exe container run -d debian:latest
				
			

You can run a container in interactive mode with Docker. In this mode, you can run commands inside the container. You can use the following command to run a container in an interactive mode:

				
					docker container run -it debian:latest /bin/bash
				
			

If you want to start, stop or remove the Docker container, run the following commands:

				
					docker container start container-name
docker container stop container-name
docker container rm container-name
				
			

Great! You have read How to Install and Run Docker on Windows Server 2016, 2019, 2022 until the very end. let’s conclude. 

How to Install and Run Docker on Windows Server 2016, 2019, 2022 Conclusion

In this post we illustrated how to install Docker CE on Windows server 2016, 2019, and 2022. We also explained how to run dotnet container in Windows server. I hope this guide will help a lot to run and manage the Docker container. Docker’s containers technology makes development highly scalable as it separates your applications from your infrastructure to be able to deliver software quickly. Shipping, testing and deploying the code is made quickly with less delays in applications delivery.

Windows Server provides many great features to run your Docker containers, including Hyper V isolation for additional security and kernel protection. Also, Microsoft Windows Server can run both Windows and Linux containers meaning you can have a mixed environment supporting applications needing both Windows and Linux components.

StarWind VSAN

Installing-the-MsftDockerProvider-and-Docker
Installing-the-MsftDockerProvider-and-Docker

Want to play around with Windows Server Docker Containers? This is easy to do with only a few steps on a Windows Server 2019 host. Additionally, you may want to do more than play around. You may have a containerized application you want to deploy and run on a Windows Server container host. This post will look at how to install Docker in Windows Server 2019 and get an overview of the step-by-step approach to running containerized applications on your Windows Server 2019 hosts.

Modernized Windows applications with Windows Server and Docker

There is no question that businesses are looking to modernize their applications to be cloud native and run microservices instead of the traditional monolithic 3-tier legacy server applications. Native Docker containers on Windows Server and Windows Desktops provides many different use cases in your Windows environment. These include:

  • Containerized Windows apps – You might envision Docker being a more Linux native solution. However, Microsoft and Docker run and work well together due to a joint partnership between Docker and Microsoft. With the native Windows integration from Docker, developers can leverage Docker containers the same way that they do on Linux, using the same Docker CLI, API, and image format. There are additional benefits to running Docker containers in Windows, including Hyper-V isolation that provides an extra layer of security to your container instances. Microsoft also continues to reduce the size of the Windows Server Core and other Windows images for use with Docker, making the footprint even smaller.
  • Run both Windows and Linux nodes on the same cluster – Using Docker enterprise, organizations can run both Windows Server and Linux nodes on the same cluster. Hybrid applications may leverage both Linux and Windows components. With Docker Enterprise, Windows containers have access to the same features as Linux containers
Running-both-Linux-and-Windows-containers-in-the-same-cluster-1
Running both Linux and Windows containers in the same cluster
  • Modernize legacy Windows Server apps – Cobine Docker Enterprise platform with built-in tools to containerize legacy Windows applications.

Let’s take a look at the steps required to install docker in Windows Server 2019. This includes a few steps that need to be taken to get the containers feature enabled as well as installing Docker and the container images. Let’s look at the following steps.

  1. Install Windows Server 2019 containers feature
  2. Install Hyper-V
  3. Install DockerMsftProvider and latest Docker version
  4. Pull Docker images
  5. Run a Docker image

1. Install Windows Server 2019 Containers feature

First, before running Docker images, we need to install the Windows Server 2019 containers feature. This installs and configures your Windows Server 2019 host for use with containerized workloads. This can easily be done using the Server Manager tool. Under Features, install Containers.

BDR Suite

Install-the-containers-feature-in-Windows-Server-2019
Install the containers feature in Windows Server 2019

You will need to reboot after the feature installation, or optionally select to reboot automatically after the feature is installed.

Finishing-the-containers-feature-installation-with-a-reboot
Finishing the containers feature installation with a reboot

2. Install Hyper-V

If you plan to use Hyper-V isolation with your Docker containers (which I highly recommend for extra security), you will need to install the Hyper-V role. This is located under Server Roles > Hyper-V.

Enabling-Hyper-V-for-Hyper-V-isolation-for-Docker-containers
Enabling Hyper-V for Hyper-V isolation for Docker containers

You can also easily install Hyper-V using PowerShell with the following command:

Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -Restart
Installing-the-Hyper-V-role-using-PowerShell-for-Hyper-V-isolation
Installing the Hyper-V role using PowerShell for Hyper-V isolation

3. Install DockerMsftProvider and latest Docker version

Next, we need to install DockerMsftProvider and the latest Docker version on our Windows Server 2019 host. To do this, run the following commands. To install the DockerMsftProvider, use:

Install-Module -Name DockerMsftProvider -Repository PSGallery -Force

Now, to install Docker:

Install-Package -Name docker -ProviderName DockerMsftProvider

After you have ran the above commands, reboot your Windows Server 2019 server. To use PowerShell, run the following:

Restart-Computer -force
Installing-the-MsftDockerProvider-and-Docker-1
Installing the MsftDockerProvider and Docker

4. Pull Docker Images

Let’s now look at pulling Docker images. This is straightforward and can be done from a PowerShell command line. To pull the LTSC Windows Server 2019 core image, use the following command:

docker pull mcr.microsoft.com/windows/servercore:ltsc2019
Downloading-and-extracting-a-Windows-Server-2019-Docker-image
Downloading and extracting a Windows Server 2019 Docker image

5. Run a Docker Image

To run a Docker image, we can do this using the following command. This will spin up a container to run a simple command.

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

If you want to run the container interactively, you will use the following command:

docker run -it mcr.microsoft.com/windows/servercore:ltsc2019
Interactive-Docker-image-running-and-listing-Docker-containers
Interactive Docker image running and listing Docker containers

Windows Docker Container Hyper-V Isolation

Windows Server 2019 Hyper-V isolation allows effectively running a container with boundaries so that the only kernel the container knows about is the Hyper-V VM container that it is provisioned inside of. This allows running multiple containers with a much higher degree of security when compared to running native Windows containers without the isolation so that the host’s kernel is shared between all running containers.

From Microsoft regarding the Hyper-V isolation mode:

This isolation mode offers enhanced security and broader compatibility between host and container versions. With Hyper-V isolation, multiple container instances run concurrently on a host; However, each container runs inside of a highly optimized virtual machine and effectively gets its own kernel. The presence of the virtual machine provides hardware-level isolation between each container as well as the container host.

Hyper-V-isolation-architecture-overview
Hyper-V isolation architecture overview
docker run -it --isolation=hyperv mcr.microsoft.com/windows/servercore:ltsc2019

Verifying Windows Server 2019 Docker Container Hyper-V Isolation

Using the command we can verify the Windows Server 2019 Docker Image Hyper-V isolation. Use the command below:

get-process -Name vmwp
Verifying-Windows-Server-2019-Hyper-V-container-isolation
Verifying Windows Server 2019 Hyper-V container isolation

Wrapping Up

The process to Install Docker in Windows Server 2019 is fairly straightforward to get Docker up and running. Windows Server 2019 provides many great features to run your Docker containers, including Hyper-V isolation for additional security and kernel protection. Also, Microsoft Windows Server 2019 can run both Windows and Linux containers meaning you can have a mixed environment supporting applications needing both Windows and Linux components. With each new Windows release including semi-channel releases, Microsoft is continuing to minimize the footprint of the Windows Docker images. These are getting smaller and more efficient.

Initially, the inception of Docker containerization started out with Linux as its base platform. However, over the years, Docker and Microsoft have continuously grown their partnership, creating a conveniently consistent interface for building, shipping, and running applications without the usual dependence hurdles associated with virtual machines.

Though a huge number of enterprises are already using Docker on Windows platforms, there has been a number of subtle functionality disparities between Windows and Linux containers. However, Windows Server 2019 (1809 build) has successfully addressed most of the inconsistencies between Docker containers in Linux and Windows environments.

Requirements for Installation of Docker on Windows

Docker containers are powered by a Docker engine. Though initially designed for Linux, extensive work has been done to allow Docker containers to run on Windows and macOS environments.

To run Docker containers on a Windows platform, one prerequisite is the installation of a Windows server. You can do this in a physical server machine, on a cloud environment running in Azure, or an on-premise virtual machine.

Install the Hyper-V feature on your Windows server 2019

There are two distinct modes to run Decker containers on Windows platforms: Process isolation and Hyper-V isolation. With the Process isolation mode, the Docker containers share the OS kernel with the host platform, hence they are lightweight and identical to Linux system Docker containers.

On the other hand, the running of Docker containers in the Hyper-V mode is confined to a special nominal virtual machine. This enables improved compatibility and secure kernel-level. To run Docker containers in this mode, you must first enable Hyper-V in the host operating system.

The default operation mode for Docker installation on a Windows server is the operation mode (enabling Hyper-V is optional). However, it’s a prerequisite to enable the Hyper-V isolation mode if you need to run Linux containers on a Windows Server interface.

The OS build is another crucial determinant on the need for Hyper-V mode as Windows containers should be of the same build version as the container host OS’s version. Still, Windows container images with a lower build version than the container host OS can run with Hyper-V isolation.

To install Hyper-V on Windows Server 2019, run the PowerShell as Administrator and run the commands below:

Enable-WindowsOptionalFeature –Online -FeatureName Microsoft-Hyper-V –All -NoRestart

Install-WindowsFeature RSAT-Hyper-V-Tools -IncludeAllSubFeature

Next, restart your Windows Server VM.

Prerequisites for the container host

You must enable virtualization in the hosting Windows server platform to utilize Hyper-V isolation in your containers: enable hardware virtualization for a container host running on hardware and nested virtualization in the base interface for a container host running on a cloud space or Hyper-V.

Running Docker Containers on Windows Server 2019

Before running multiple isolated applications using Windows Containers, you need to activate (enable) the containers feature and install Docker on your Windows Server 2019. Here’s the process:

  1. Enable the containers feature in Windows Server 2019.

Run PowerShell as an Administrator and run this command:

Install-Module -Name DockerMsftProvider -Repository PSGallery -Force

This command will install the Docker-Microsoft Package Management Provider from the PowerShell Gallery.

When prompted to install and import NuGet provider, type Y and hit ENTER

  1. Install Docker on your Windows Server 2019

After installing the Containers feature on Windows Server 2019, it’s time to install the latest versions of Docker Engine and Docker Client. Run this command in your PowerShell session:

Install-Package -Name docker -ProviderName DockerMsftProvider

Accept the installation by selecting “Yes”, “Y” or “A” to Agree to all the installation requests.

After the completion of this installation, reboot your computer.

Restart-Computer –Force

You can check your installed Docker version via the PowerShell command:

Get-Package -Name Docker -ProviderName DockerMsftProvider


You can also confirm the installed Docker version using the docker –version command:

docker –version

You can opt to upgrade anytime by running the commands below on PowerShell:

Install-Package -Name Docker -ProviderName DockerMsftProvider -Update -Force

Then start the docker service.

Start-Service Docker

  1. Launch (Run) Docker Containers on Windows Server 2019

Run the following commands on PowerShell:

Start-Service Docker

After starting the Docker Engine service, proceed to download the pre-created .NET sample image on the Docker Hub registry:

docker pull microsoft/dotnet-samples:dotnetapp-nanoserver-1809

After the download, you can deploy a simple Docker container that runs the .Net ‘Hello World’ application:

docker run microsoft/dotnet-samples:dotnetapp-nanoserver-1809

After running the command, an ASCII image will be printed to the shell accompanied by the “Hello” message.

Running Linux Containers on your Window Server 2019

By default, Docker on Windows only runs Windows containers. To launch Linux containers on Windows Server, use the Docker Enterprise Edition Preview that comes with a full LinuxKit system to run Docker Linux containers.

  1. First, uninstall the already installed Docker CE.

Uninstall-Package -Name docker -ProviderName DockerMSFTProvider

  1. Enable Nested Virtualization in case you’re running Docker Containers on a Linux Virtual Machine running on Hyper-V.

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

NOTE: WinContainerHost is the name of your virtual machine

  1. Install the Module Docker Provider

Install-Module DockerProvider

Install-Package Docker -ProviderName DockerProvider -RequiredVersion preview

A restart will be required after this operation

  1. Enable LinuxKit system to run Linux containers

[Environment]::SetEnvironmentVariable(“LCOW_SUPPORTED”, “1”, “Machine”)

  1. Restart the Docker Service after the change above and restart the Service Docker

Restart-Service docker

To switch back to running Windows containers, execute the following command in PowerShell:

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

You have finally installed and configured Docker your Windows Server machine to run both Linux and Windows containers. We hope this guide was insightful.

Windows Server 2019 is the next long-term support release of Windows Server, and it’s available now! It comes with some very useful improvements to running Docker Windows containers — which Docker Captain Stefan Scherer has already summarized in his blog post What’s new for Docker on Windows Server 2019.

UPDATE: the second edition of my book Docker on Windows is out now. It focuses entirely on Windows Server 2019

You need Windows Server to run «pure» Docker containers, where the container process runs directly on the host OS. You can use the same Docker images, the same Dockerfiles and the same docker commands on Windows 10, but there’s an additional virtualization overhead, so it’s good to use a Windows Server VM for test environments.

On Windows 10 Docker Desktop is the easiest way to get started

If you want to check out the newest version of Windows Server and get running Docker containers, here’s what you need to do.

Get Windows Server 2019

You can download the ISO to install Windows Server 2019 now, from your Visual Studio subscription if you have one, or a 180-day evaluation version if you don’t. VMs with Windows Server 2019 already deployed will be available on Azure shortly.

The installation procedure for 2019 is the same as previous Windows Server versions — boot a VM from the ISO and the setup starts. I prefer the core installation with no GUI:

Installing Windows Server 2019 Core

I installed Server 2019 onto a Hyper-V VM running on my Windows 10 machine, with the VM disks stored on an external SSD drive. The setup finished in a few minutes, and it runs very quickly — even with just 4GB RAM allocated.

You can also upgrade from previous Windows Server versions to 2019 using the ISO.

Connect to the Server

When you RDP into a Windows Server Core machine you just see a command prompt. The first time you connect you’ll need to set the password for the default Administrator account. Then I like to set PowerShell as the default command shell, so whenever you RDP you get into a PowerShell session:

Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -name Shell -Value 'PowerShell.exe -noExit'  

Configure Windows Features

To run containers you need to enable the Containers feature, and for a non-production VM I also disable Windows Defender to stop it burning CPU cycles. You’ll need to reboot after these steps:

Install-WindowsFeature -Name Containers

Uninstall-WindowsFeature Windows-Defender

Restart-Computer -Force  

Configure Windows Updates

You’ll want to make sure you have the latest updates, but then I disable automatic updates so I only get future updates when I want them. There’s no GUI in Windows Server Core, so run sconfig and then select:

  • option 5, to set Windows Updates to manual

  • option 7, to enable Remote Desktop Access to the server

  • option 6, to download and install all updates

Then you’re ready to install Docker.

Install Docker on Window Server 2019

Windows Server licensing includes the licence cost for Docker Enterprise, so you can run the enterprise edition with production support for containers from Microsoft and Docker.

The latest Docker Enterprise engine is version 19.03 18.03, which you can explicitly install with PowerShell:

Install-Module -Name DockerMsftProvider -Repository PSGallery -Force

Install-Package -Name docker -ProviderName DockerMsftProvider -Force -RequiredVersion 19.03  

This sets up Docker as a Windows Service, which you need to start:

Start-Service docker  

Pull the Windows Base Images

Any Docker containers you run on Windows Server 2019 will be based on Windows Server Core or Nano Server. You’ll need both those images, and be aware that the base images are now hosted on Microsoft’s container registry, MCR:

docker image pull mcr.microsoft.com/windows/servercore:ltsc2019

docker image pull mcr.microsoft.com/windows/nanoserver:1809  

These images are tiny compared to the Windows Server 2016 versions. Windows Server Core has shrunk from over 10GB to a 1.5GB download, and Nano Server has shrunk from over 1GB to a 90MB download!

[Optional] Pull the .NET Core Images

The .NET Core team released versions of their SDK and runtime images as soon as Windows Server 2019 launched. You can pull those now and start running your .NET Core apps in 2019 (there are also .NET Framework SDK and ASP.NET images available — hopefully SQL Server will get some attention soon…)

docker image pull mcr.microsoft.com/dotnet/core/aspnet:3.0

docker image pull mcr.microsoft.com/dotnet/core/sdk:3.0.100  

The upstream Docker images are still listed on Docker Hub, so that’s where you go for discovery — but they get served from Microsoft’s own image registry, MCR.

Try it Out!

I’ve pushed an updated version of my .NET Core whoami image, so you can try out ASP.NET Core 3.0 running in Windows Server Core 2019 containers:

docker container run -d -p 8080:80 sixeyed/whoami-dotnet:3.0  

One of the enhancements for Docker in Windows Server 2019 is that loopback addresses now work, so you can visit this container using localhost on the server, and using the same published port from an external machine:

Published ports now do loopback

And in Swarm Mode…

I’ll post a longer explanation of what you can do with Docker in Windows Server 2019 that you couldn’t do in Windows Server 2016, but here’s just one other thing: Windows Server 2019 now supports ingress networking for Docker swarm mode. That means you can run multiple containers on one server, all listening on the same port, and Docker will load-balance incoming requests between the containers.

I have lots more detail on this in my Pluralsight course Managing Load Balancing and Scale in Docker Swarm Mode Clusters

Switch your server to a single-node swarm:

docker swarm init --advertise-addr 127.0.0.1  

Now deploy the whoami app as a swarm service, with multiple replicas and a published port:

docker service create `  
  --publish 8070:80 `
  --replicas 5 `
  sixeyed/whoami-dotnet:nanoserver-1809

Now when you browse to the VM from outside, Docker will load-balance requests across the five containers which are hosting the service:

whoami in swarm mode

There’s More

Windows Server 2019 is an evolution to the container functionality you get with Docker. Windows Server 2016 is still perfectly fine for production, but 2019 brings Windows containers much closer to feature parity with Linux containers, and smooths over some things which are tricky in 2016.

And the next big thing is Windows support in Kubernetes, which is expected to GA before the end of the year :) went GA this year. Windows containers are now supported in mixed Linux-Windows Kubernetes clusters — find out more from my post Getting Started with Kubernetes on Windows.

  • Установка inpa bmw на windows 10
  • Установка dns на windows server 2016
  • Установка dis bmw на windows 7
  • Установка iperf3 на windows 10
  • Установка ftp сервера на windows server 2019