開始使用:準備適用於容器的 WindowsGet started: Prep Windows for containers

本教學課程說明如何:This tutorial describes how to:

  • 設定適用於容器的 Windows 10 或 Windows ServerSet up Windows 10 or Windows Server for containers
  • 執行您的第一個容器映像Run your first container image
  • 容器化簡單的 .NET core 應用程式Containerize a simple .NET core application

必要條件Prerequisites

若要在 Windows Server 上執行容器,您需要執行 Windows Server (半年通道)、Windows Server 2019 或 Windows Server 2016 的實體伺服器或虛擬機器。To run containers on Windows Server, you need a physical server or virtual machine running Windows Server (Semi-Annual Channel), Windows Server 2019, or Windows Server 2016.

若要進行測試,您可以下載 Windows Server 2019 評估版Windows Server Insider Preview 的複本。For testing, you can download a copy of Windows Server 2019 Evaluation or a Windows Server Insider Preview.

安裝 DockerInstall Docker

第一個步驟是安裝 Docker,這是使用 Windows 容器的必要條件。The first step is to install Docker, which is required for working with Windows containers. Docker 提供適用於容器的標準執行階段環境,其中包含通用 API 和命令列介面 (CLI)。Docker provides a standard runtime environment for containers, with a common API and command-line interface (CLI).

如需更多設定詳細資料,請參閱 Windows 上的 Docker 引擎For more configuration details, see Docker Engine on Windows.

若要在 Windows Server 上安裝 Docker,您可以使用由 Microsoft 發佈,稱為 DockerMicrosoftProviderOneGet 提供者 PowerShell 模組To install Docker on Windows Server, you can use a OneGet provider PowerShell module published by Microsoft called the DockerMicrosoftProvider. 此提供者會在 Windows 中啟用容器功能,並安裝 Docker 引擎和用戶端。This provider enables the containers feature in Windows and installs the Docker engine and client. 方法如下:Here's how:

  1. 開啟提升權限的 PowerShell 工作階段,並且從 PowerShell 資源庫安裝 Docker-Microsoft PackageManagement 提供者。Open an elevated PowerShell session and install the Docker-Microsoft PackageManagement Provider from the PowerShell Gallery.

    Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
    

    如果系統提示您安裝 NuGet 提供者,請輸入 Y 以進行安裝。If you're prompted to install the NuGet provider, type Y to install it as well.

  2. 使用 PackageManagement PowerShell 模組安裝最新版 Docker。Use the PackageManagement PowerShell module to install the latest version of Docker.

    Install-Package -Name docker -ProviderName DockerMsftProvider
    

    當 PowerShell 詢問是否要信任封裝來源 'DockerDefault' 時,輸入 A 以繼續安裝。When PowerShell asks you whether to trust the package source 'DockerDefault', type A to continue the installation.

  3. 安裝完成後,重新啟動電腦。After the installation completes, restart the computer.

    Restart-Computer -Force
    

如果您想要稍後再更新 Docker:If you want to update Docker later:

  • 若要查看已安裝的版本,請使用:Check the installed version with:
Get-Package -Name Docker -ProviderName DockerMsftProvider
  • 若要尋找最新版本,請使用:Find the current version with:
Find-Package -Name Docker -ProviderName DockerMsftProvider
  • 準備就緒後,請使用下列方式進行升級:When you're ready, upgrade with:
Install-Package -Name Docker -ProviderName DockerMsftProvider -Update -Force

,再加上:, followed by

Start-Service Docker

接下來的步驟Next steps

現在您已正確設定您的環境,請遵循連結以了解如何執行容器。Now that your environment has been configured correctly, follow the link to learn how to run a container.