容器基底映像Container Base Images

Windows 提供四個可供使用者據以建置的容器基底映像。Windows offers four container base images that users can build from. 每個基底映像都是不同的 Windows 作業系統類型、具有不同的磁碟使用量,而且有不同的 Windows API 集。Each base image is a different type of the Windows operating system, has a different on-disk footprint, and has a different set of the Windows API set.

映像探索Image discovery

所有 Windows 容器基底映像都可透過 Docker Hub 探索。All Windows container base images are discoverable through Docker Hub. Windows 容器基底映像本身是由 Microsoft Container Registry (MCR) (mcr.microsoft.com) 提供。The Windows container base images themselves are served from mcr.microsoft.com, the Microsoft Container Registry (MCR). 這就是 Windows 容器基底映像的提取命令為何看起來如下所示:This is why the pull commands for the Windows container base images look like the following:

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

MCR 沒有自己的目錄體驗,目的是要支援 Docker Hub 等現有目錄。The MCR does not have its own catalog experience and is meant to support existing catalogs such as Docker Hub. 由於 Azure 的全域磁碟使用量並與 Azure CDN 結合,MCR 才能提供一致且快速的映像提取體驗。Thanks to Azure’s global footprint and coupled with Azure CDN, the MCR delivers an image pull experience that is consistent and fast. 在 Azure 中執行其工作負載的 Azure 客戶,可受惠於網路效能增強功能以及與 MCR (Microsoft 容器映像的來源) 緊密整合、Azure Marketplace,還有 Azure 中可提供容器作為部署套件格式的擴充服務數目。Azure customers, running their workloads in Azure, benefit from in-network performance enhancements as well as tight integration with the MCR (the source for Microsoft container images), Azure Marketplace, and the expanding number of services in Azure that offer containers as the deployment package format.

選擇基底映像Choosing a base image

如何選擇所要依據的正確基底映像?How do you choose the right base image to build upon? 對於大部分的使用者而言,Windows Server CoreNanoserver 會是所要使用的最適當映像。For most users, Windows Server Core and Nanoserver will be the most appropriate image to use.

指導方針Guidelines

雖然您可自由地以您想要的任何映像作為目標,但以下是一些可協助您進行選擇的指導方針:While you're free to target whichever image you wish, here are some guidelines to help steer your choice:

  • 您的應用程式是否需要完整的 .NET Framework?Does your application require the full .NET framework? 如果這個問題的答案是肯定的,您應該以 Windows Server Core 為目標。If the answer to this question is yes, you should target Windows Server Core.
  • 您是否正在建置以 .NET Core 為基礎的 Windows 應用程式?Are you building a Windows app based upon .NET Core? 如果這個問題的答案是肯定的,您應該以 Nanoserver 為目標。If the answer to this question is yes, you should target Nanoserver.
  • 您正在建置 IoT 應用程式嗎?Are you building an IoT application? 如果這個問題的答案是肯定的,您應該以 IoT Core 為目標。If the answer to this question is yes, you should target IoT Core.
  • Windows Server Core 容器映像是否遺漏您的應用程式所需的相依性?Is the Windows Server Core container image missing a dependency your app needs? 如果這個問題的答案是肯定的,您應該嘗試以 Windows 為目標。If the answer to this question is yes, you should attempt to target Windows. 此映像遠大於其他基底映像,但是其含有許多核心 Windows 程式庫 (例如 GDI 程式庫)。This image is much larger than the other base images, but it carries many of the core Windows libraries (such as the GDI library).
  • 您是 Windows 測試人員嗎?Are you a Windows Insider? 如果是,您應該考慮使用測試人員版本的映像。If yes, you should consider using the insider version of the images. 請參閱下面「適用於 Windows 測試人員的基底映像」。See "Base images for Windows insiders" below.

提示

許多 Windows 使用者都想要容器化相依於 .NET 的應用程式。Many Windows users want to containerize applications that have a dependency on .NET. 除了此處所述的四個基底映像之外,Microsoft 還發佈了數個已預先設定熱門 Microsoft 架構的 Windows 容器映像,例如 .NET Framework 映像和 ASP .NET 映像。In addition to the four base images described here, Microsoft publishes several Windows container images that come pre-configured with popular Microsoft frameworks, such as a the .NET framework image and the ASP .NET image.

適用於 Windows 測試人員的基底映像Base images for Windows Insiders

Microsoft 會提供每個容器基底映像的「測試人員」版本。Microsoft provides "insider" versions of each container base image. 這些測試人員容器映像會包含我們的容器映像中最新且最棒的功能開發。These insider container images carry the latest and greatest feature development in our container images. 當您執行的主機是 Windows 測試人員版本 (Windows Insider 或 Windows Server Insider) 時,最好使用這些映像。When you're running a host that is an insider version of Windows (either Windows Insider or Windows Server Insider), it is preferable to use these images. 您可以在 Docker Hub 上取得測試人員映像:The insider images are available on Docker Hub:

如需深入了解,請參閱透過 Windows 測試人員計畫使用容器Read Use Containers with the Windows Insider Program to learn more.

Windows Server Core 與 NanoserverWindows Server Core vs Nanoserver

Windows Server CoreNanoserver 是可作為目標的最常見基底映像。Windows Server Core and Nanoserver are the most common base images to target. 這些映像的主要差異在於 Nanoserver 有一個明顯較小的 API 表面。The key difference between these images is that Nanoserver has a significantly smaller API surface. Nanoserver 映像中不存在 PowerShell、WMI 和 Windows 服務堆疊。PowerShell, WMI, and the Windows servicing stack are absent from the Nanoserver image.

建置 Nanoserver 是為了提供足夠的 API 表面,以執行相依於 .NET Core 或其他新式開放原始碼架構的應用程式。Nanoserver was built to provide just enough API surface to run apps that have a dependency on .NET core or other modern open source frameworks. 折衷使用較小的 API 表面,Nanoserver 映像的磁碟使用量明顯小於其餘的 Windows 基底映像。As a tradeoff to the smaller API surface, the Nanoserver image has a significantly smaller on-disk footprint than the rest of the Windows base images. 請記住,您隨時都可以視需要在 Nano Server 之上新增層級。Keep in mind that you can always add layers on top of Nano Server as you see fit. 如需範例,請參閱 .NET Core Nano Server DockerfileFor an example of this check out the .NET Core Nano Server Dockerfile.