在 Windows Server 上安裝 Docker EE 引擎
Windows Server 必須是 2016 或更新的版本才可在上面安裝 Docker EE引擎。
以 Administrator 權限身份,打開 PowerShell, 輸入下列命令進行引擎安裝
$ Install-Module DockerProvider -Force
$ Install-Package Docker -ProviderName DockerProvider -Force
重新啟動系統
$ Restart-Computer
啟動 Docker 命令:
$ Start-Service Docker
或是在系統管理中,找到 docker 服務,並且改為開機自動啟動選項。
如果是在 air-gapped 環境下,上述做法不可行。可以先在外部工作機下載 zip 文件,
https://download.docker.com/components/engine/windows-server/19.03/docker-19.03.1.zip
再拷貝到內部伺服器主機中,依序執行下列命令完成安裝。也可以先將下列命令單獨寫成 PowerShell 腳本文件,配合下載好的 Docker ZIP 文件,批次完成安裝作業。
# Extract the archive.
Expand-Archive docker-19.03.1.zip -DestinationPath $Env:ProgramFiles -Force
# Clean up the zip file.
# Remove-Item -Force docker-19.03.1.zip
# Install Docker. This requires rebooting.
$null = Install-WindowsFeature containers
# Add Docker to the path for the current session.
$env:path += ";$env:ProgramFiles\docker"
# Optionally, modify PATH to persist across sessions.
$newPath = "$env:ProgramFiles\docker;" +
[Environment]::GetEnvironmentVariable("PATH",
[EnvironmentVariableTarget]::Machine)
[Environment]::SetEnvironmentVariable("PATH", $newPath,
[EnvironmentVariableTarget]::Machine)
# Register the Docker daemon as a service.
dockerd --register-service
# Start the Docker service.
Start-Service docker
最後,我們可以用下列命令來確認 Docker 引擎已經安裝完成(在 PowerShell 下命令):
PS> docker container run hello-world:nanoserver Unable to find image 'hello-world:nanoserver' locally nanoserver: Pulling from library/hello-world bce2fbc256ea: Pull complete 3ac17e2e6106: Pull complete 8cac44e17f16: Pull complete 5e160e4d8db3: Pull complete Digest: sha256:25eac12ba40f7591969085ab3fb9772e8a4307553c14ea72d0e6f98b2c8ced9d Status: Downloaded newer image for hello-world:nanoserver Hello from Docker! This message shows that your installation appears to be working correctly.
看到上述最後一行訊息就是代表 Docker EE Engine 在 Windows Server 2016 安裝成功了。
如要解除安裝,執行下列命令
Uninstall-Package -Name docker -ProviderName DockerProvider Uninstall-Module -Name DockerProvider Remove-Item -Path "C:\ProgramData\Docker" -Recurse -Force
註:在作業系統組建 14393.1066 和 14393.1083,
安裝系統補丁 KB4015217 , 包含了改善 HNS ,以支援 Overlay 網路驅動
在 PowerShell 輸入
$ sconfig
將會看到選單,選擇 6) Download and Install Updates
【參考資料】
https://docs.docker.com/install/windows/docker-ee/
留言
張貼留言