Redigera

Dela via


Get started: Prep Windows for containers

Applies to: Windows Server 2022, Windows Server 2019, Windows Server 2016, Windows 10 and 11

This tutorial describes how to:

Prerequisites

Windows 10 and 11

To run containers on Windows 10 or 11, you need the following:

  • One physical computer system running Windows 10 or 11 Professional or Enterprise with Anniversary Update (version 1607) or later.
  • Hyper-V should be enabled.

Note

Starting with the Windows 10 October Update 2018, Microsoft no longer disallows users from running a Windows container in process-isolation mode on Windows 10 Enterprise or Professional for development or test purposes. See the FAQ to learn more.

Windows Server Containers use Hyper-V isolation by default on Windows 10 and 11 to provide developers with the same kernel version and configuration that will be used in production. To learn more about Hyper-V isolation, see Isolation Modes.

Windows Server

For development environments, to run Windows Server Containers you will need a physical server or virtual machine running Windows Server.

For testing, you can download a copy of Windows Server 2022 Evaluation or a Windows Server Insider Preview.

Container-Ready Azure VMs

For many applications and orchestration paradigms it is necessary to build and deploy your own custom VMs. With the transition of support for the Windows Container Runtime to Mirantis, the container runtime is no longer provided with a marketplace VM offering. The remainder of this guide details how you can build a VM for Azure with the container runtime installed and ready to go.

Azure will continue to offer a complete and fully managed end-to-end experience through the Azure Kubernetes Service both in the cloud and on-premises. AKS and AKS-HCI are fully managed services with lower management overhead than what you are used to with custom deployments. Support for the container runtime is included within the AKS and AKS-HCI services under your Azure subscription.

There are three things to keep in mind when considering the following options. It is up to your organization to decide which aspect you want to optimize around:

  1. How complex is it to implement?
  2. What is the cost?
  3. How does it impact my workload in production?

Each of these methods are provided as an option to make the experience of constructing your container-ready Azure VMs as smooth as possible. The following subsections will detail the pros and cons of each option alongside how to get started.

Azure Image Builder

The benefit to using Image Builder is that the configuration is done during a build time and would not have any effect on your workload at runtime; when the VM scale set instantiates a new VM from your custom image, the image will have already been prepped so no time must be spent here and it will be immediately ready to run containers.

Azure image builder, however, can be more complex to implement and there are more steps involved than with script extensions. Additionally, while the Image Builder service is free, you must manage for the compute, storage, and networking usage associated with the build process (additional details here)

To get started with building your own Windows Server VM image, we have created a guide which details the process step-by step. The powershell scripts mentioned below can be utilized alongside this guide to install your container runtime of choice.

Tip

Make sure to cache the container images you plan to use locally on the VM! This will help improve the container start time after deployment. The scripts below will help you do this.

Custom Script Extensions

Custom Script Extensions are quicker to implement and the cost is only in the nominal price to store the script in Azure or GitHub. However, the script may only execute after a VM has been provisioned, so you must budget for additional time being spent to properly prep the VM at scale-out time.

Using the scripts offered below you can configure your VM scale sets to install the container runtime of your choice upon provisioning. Follow our guide learn how to set a custom script extension.

Install the Container Runtime

Windows 10 and 11

You can install Docker on Windows 10 or 11 Professional and Enterprise editions by using the following steps.

  1. Download and install Docker Desktop and create a Docker account if you don't already have one. You can create a free Docker account for personal or small business users, however, for larger businesses, there is a monthly fee. For more details, see the Docker documentation.

  2. During installation, set the default container type to Windows containers. To switch after installation completes, you can use either the Docker item in the Windows system tray (as shown below), or the following command in a PowerShell prompt:

    & $Env:ProgramFiles\Docker\Docker\DockerCli.exe -SwitchDaemon .
    

    Docker system tray menu showing the "Switch to Windows containers" command

Windows Admin Center

You can use Windows Admin Center to properly set up a Windows Server machine as a container host. To get started, ensure you have the latest Containers extension installed on your Windows Admin Center instance. For more information on how to install and configure extensions, check out the Windows Admin Center documentation. With the Containers extension installed, target the Windows Server machine you want to configure and select the Containers option:

Install Docker

Click the Install button. Windows Admin Center will start the configuration of Windows Server and Docker in the background. After the process is complete, you can refresh the page and see the other functionalities of the Containers extension.

Container images

Windows Server

To run a Windows container you must have a supported container runtime available on your machine. The runtimes currently supported on Windows are containerd, Moby, and the Mirantis Container Runtime.

This section will detail the process of installing each on your specific copy of Windows, including a set of powershell scripts which make it easy to install each runtime in just a few steps.

Docker Community Edition (CE) provides a standard runtime environment for containers with a common API and command-line interface (CLI). It is managed by the open source community as part of the Moby Project.

To get started with Docker on Windows Server we have created a powershell script which configures your environment to enable container-related OS features and install the Docker runtime.

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/Windows-Containers/Main/helpful_tools/Install-DockerCE/install-docker-ce.ps1" -o install-docker-ce.ps1
.\install-docker-ce.ps1

For more configuration details, see Docker Engine on Windows.

Next steps

Note

If you have read this guide and would like additional guidance from the Windows Containers product team, you can reach us at github/Windows-Containers where you will find information about getting time on the product team’s calendar to chat.

Now that your environment has been configured correctly, follow the link to learn how to run a container.