Windows Server 2019 容器化探索-Docker安裝

Docker on Windows Server 2019

微軟自Windows Server 2016開始支持Docker,今天咱們將介紹在Windows Server 2019上安裝並使用Docker容器。html

Install Docker EE on windows server 2019

  1. 啓用服務器Hyper-V,Containers特性
Install-WindowsFeature -Name Hyper-V,Containers -IncludeAllSubFeature -IncludeManagementTools
  1. Install Docker EE
Install-Module DockerMSFTProvider

Import-Module -Name DockerMSFTProvider -Force

Import-Packageprovider -Name DockerMSFTProvider -Force

經過Find-Package docker確認是否安裝成功linux

PS C:\Users\Administrator> Find-Package docker

Name                           Version          Source           Summary
----                           -------          ------           -------
Docker                         1.3.2            PSGallery        This module helps with development using Docker on localhost. It ...
Docker                         18.09.5          DockerDefault    Contains Docker EE for use with Windows Server.

安裝Dockergit

Install-Package -Name Docker -Source DockerDefault

啓用Docker Linux Container Supportgithub

==目前基於Windows Container只能運行Windows應用程序。==redis

# Set LCOW_SUPPORTED Variable to 1 for enabled
[Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", "1", "Machine")

# Enable Experimental Features in Dockerd daemon.conf
$configfile = @"
{
    "experimental": true
}
"@
$configfile|Out-File -FilePath C:\ProgramData\docker\config\daemon.json -Encoding ascii -Force

在Docker使用 Linux Container時,仍然須要使用Linux kernal。
You should use the latest LCOW release heredocker

Invoke-WebRequest -Uri "https://github.com/linuxkit/lcow/releases/download/v4.14.35-v0.3.9/release.zip" -UseBasicParsing -OutFile release.zip

Expand-Archive release.zip -DestinationPath "$Env:ProgramFiles\Linux Containers\."

Redis on Docker Linux Container

如今咱們便可使用 Windows Container或者Linux Container,可是因爲目前基於Windows Container只能運行Windows應用程序,因此咱們須要使用--platform選擇一種容器類型,參考以下shell

docker run --platform=linux --name redis-server -d -p 6379:6379 --restart=always redis

References

  1. Posted on February 12, 2019 by Ben Thomas,Getting started with Linux Containers on Windows Server 2019
  2. November 16, 2018 by Andy Syrewicze (Chief Editor) ,How to Run 🐧 Linux Containers on Windows Server 2019
  3. posted @ 2017-02-10 11:40 北京的201個藍天,Windows Container 和 Docker:你須要知道的5件事

原文出處:https://www.cnblogs.com/yankliu-vip/p/Docker-on-Windows-Server-2019.htmljson

相關文章
相關標籤/搜索