Установка 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 остановит работу контейнера и удалит его.

In this series, we will try to sort out confusing topics such as Docker Engine Enterprise Edition (EE) vs. Docker Enterprise, Docker Engine Community Edition (CE) vs. Docker Desktop, dockerd vs. docker vs. containerd vs. runc, and so on.

Contents

  1. Install the Hyper-V feature
  2. Container host prerequisites
  3. Install the containers feature
  4. Install Docker
  5. Docker verification
  6. Launch a Windows container on Windows Server 2019
  • Author
  • Recent Posts

Swapnil Kambli is a cloud consultant and trainer specializing in cloud adoption, migration, support, and optimization. He has 14 years of experience advising enterprises in areas ranging from containers to server management, virtualization to cloud computing, automation to DevOps, system administration to site-reliability engineering, and systems management to governance.

Latest posts by Swapnil Kambli (see all)

  • Install Docker on Windows Server 2019 — Tue, Jun 25 2019

We’ll also try to understand the current state of Docker on Windows by demystifying the differences between the Docker experience on Windows and Linux. In today’s article, we will begin with launching our first Windows container on Windows Server 2019, and along the way, we will go through some of the current aspects of Docker on Windows.

When Docker first released a containerization product, they started with Linux as a base platform. In 2014, Docker and Microsoft announced partnership to provide a consistent platform to build, ship, and run any application. On Windows Server 2016, Docker and Microsoft came out with container technology that provided a consistent experience across both Linux and Windows Server environments.

In 2017, they released Docker Swarm with the ability to create mixed Windows Server and Linux clusters. In 2018, this release followed with added support for the Semi-Annual Channel (SAC) Windows Server 1709 and 1803 versions. With Windows Server 2019 (the 1809 build), Microsoft managed to bring the containers to Windows on par with containers on Linux systems.

At present, thousands of enterprise customers are widely using Docker on Windows in production environments. However, there’s always been a subtle functionality difference between Windows containers and Linux containers. Microsoft Windows Server is closing that gap rapidly with new releases.

Install the Hyper-V feature

On Windows platforms, you can run containers in two modes: process isolation and Hyper-V isolation. In process isolation mode, containers share the OS kernel with the host and hence are lightweight and similar to how containers work on Linux systems.

Conversely, in Hyper-V isolation mode, each container runs inside a special minimal virtual machine. Thus, it provides secure kernel-level isolation and enhanced compatibility. You need to enable Hyper-V in the host OS to run containers in Hyper-V isolation mode.

When we install Docker on a Windows server, the default mode of operation is process isolation. And enabling Hyper-V is optional. However, if we need to run Linux containers, enabling Hyper-V is required.

The second factor that determines whether to go for the Hyper-V feature is the OS build. Windows containers need to have the same build version as the version of the container host OS they run on. Container images tagged as 1809 would work on the latest 1809 Windows version builds. However, if we have built container images on a lower version of Windows than the container host OS, we can run these containers with Hyper-V isolation, which requires enabling Hyper-V.

You can install Hyper-V on Windows Server using the PowerShell command below:

Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -Restart

Also, we need to note here that we can switch between process isolation and Hyper-V isolation during runtime using the parameter isolation while spinning up Docker containers.

Container host prerequisites

Though this article’s scope is for Windows Server 2019 (1809), the steps demonstrated here could also very well apply to other Windows Server builds, including Windows Server version 1803, Windows Server version 1709, and Windows Server 2016.

If you want to use Hyper-V isolation in your container, you need to enable virtualization in the hosting platform. If the container host is running on hardware, you need to enable the hardware virtualization feature, such as Intel VT-x, in BIOS. And if the container host is running from Hyper-V or from a cloud environment, you need to enable nested virtualization in the base platform.

Install the containers feature

For containerization to work, you need to install the Windows container feature on the Windows container host. Use the command below to install the containers feature and reboot the computer.

Install-WindowsFeature containers -Restart

Install the Containers feature

Install the Containers feature

Install Docker

Docker consists of two major components: the Docker engine and the Docker client. The Docker engine is available in two editions: Docker Engine CE and Docker Engine EE. The Docker Engine CE is a free product. Conversely, the Docker Engine EE requires a license. The diagram below illustrates the architectural difference between the two.

Docker Engine architecture

Docker Engine architecture

From a user-experience perspective, Docker provides two sets of products or packaged bundles: namely, Docker Desktop and Docker Enterprise.

As for Docker Desktop Community/Enterprise, they designed this product set considering developers and a development environment in mind. Docker Desktop provides an installation wizard, a management UI, and several other utilities for improving deployment. Docker Desktop is supported on Windows 10 and Mac. Docker Desktop comes with the Docker Engine CE or EE depending on the product tier we choose.

Docker targets its enterprise product suite toward production environments. This includes the Docker enterprise engine along with its certified plug-ins, well-integrated product line, and trusted repositories. Overall, it aligns with the enterprise requirements for use in a production environment.

In this article, we are going to install Docker Engine EE on Windows Server 2019. To get the full functionality of the EE edition, we need to purchase the EE license from Docker.

The process for installing Docker EE on Windows Server is quite simple with the introduction of the OneGet provider PowerShell Module. As a first step, install the Docker-Microsoft PackageManagement Provider module from the PowerShell Gallery.

Install-Module -Name DockerMsftProvider -Repository PSGallery -Force

Install the Docker package provider

Install the Docker package provider

We can use the commands below to view the installed package provider and the Docker package made available through it.

Get-PackageProvider -ListAvailableget-packagesource -ProviderName DockerMsftProvider

Display the installed package provider

Display the installed package provider

Next, we will use the PackageManagement PowerShell module command Install-Package to install the latest version of Docker.

Install-Package -Name docker -ProviderName DockerMsftProvider

Install the Docker package

Install the Docker package

Docker verification

After installing the Docker package and we have our command prompt back, we need to start the Docker service using the command below.

Start-Service Docker

When we run the Docker service for the first time, it creates a virtual switch/interface viewable through our Control Panel pane.

Installed network virtual switch

Installed network virtual switch

Also, we can verify the Docker virtual network creation using the Docker command below. The default name of the bridge or switch in a Windows environment is NAT.

docker network ls

List Docker networks

List Docker networks

This virtual switch lays the foundation of networking for containers to communicate with each other as well as talk with the container host.

Next, we can run the Docker version command to check the details of our deployment setup. We can verify the Docker engine and client version from the command output.

docker version

Check the Docker version

Check the Docker version

And lastly, to confirm the Docker client-engine communication is working fine and installation is complete, run the command docker info. This provides us with system metadata along with the current container stats.

Check system container info

Check system container info

Launch a Windows container on Windows Server 2019

Now that we have completed the installation and verified everything is working smoothly, it’s time to run our first Windows container on Docker.

Here we need to consider two factors. First, we can create Windows container images with four container base images: Windows Server Core, Nano Server, Windows, and IoT Core.

When we spin a container from these images, we need to verify the compatibility between the container host OS and the container base image. In other words, containers based on Windows Server Core, Nano Server, or Windows as the base image can run on a Windows 2019 container host. However, a container based on an IoT Core image cannot run on Windows Server 2019. An IoT Core container requires Windows IoT Core as a container host.

Second, to repeat, Windows containers need to match the version of the container host OS. Container images with the 1809 tag work with the latest Windows versions. However, if we have container images built on a lower version of Windows than the container host OS, we can run these containers with Hyper-V isolation

Considering these two factors, let’s verify the build version of our container host.

winver

Check the Windows version

Check the Windows version

As the container host build version is 1809, let’s try to download a Nano Server image from the Microsoft image/container registry to the local machine.

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

Pull a Docker Nano Server image

Pull a Docker Nano Server image

We can verify the locally available image along with its metadata information, such as size, image ID, and creation date.

docker image ls

List locally available images

List locally available images

We can use the downloaded image for baking our application into it and creating a new container. But for simplicity, let’s launch a basic container that will run just a simple command inside the OS and exit.

docker container run mcr.microsoft.com/windows/nanoserver:1809 hostname

Create and run a Docker container

Create and run a Docker container

This command created a new container from the Windows Nano Server image, and the container outputted the machine name of the container, a random ID set by Docker. To see more information about the container we created just now, run the command below.

Subscribe to 4sysops newsletter!

docker container ls -a

List Docker container information

List Docker container information

Thus, we have launched a Windows container on Windows Server 2019, considering some of the factors for Docker on Windows. In the next article, we’ll discuss Linux containers on Windows (LCOW), LinuxKit, Windows Subsystem for Linux 2 and how to run your first Linux container on Windows Server 2019.

avataravatar

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.

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.

  • Установка ista bmw на windows 10
  • Установка git windows пошаговая инструкция
  • Установка docker на windows server 2019
  • Установка dns на windows server 2016
  • Установка inpa bmw на windows 10