Windows Server 2019 容器化探索-Docker安装
Docker on Windows Server 2019
微软自Windows Server 2016开始支持Docker,今天我们将介绍在Windows Server 2019上安装并使用Docker容器。
Install Docker EE on windows server 2019#
- 启用服务器Hyper-V,Containers特性
Install-WindowsFeature -Name Hyper-V,Containers -IncludeAllSubFeature -IncludeManagementTools
- Install Docker EE
Install-Module DockerMSFTProvider
Import-Module -Name DockerMSFTProvider -Force
Import-Packageprovider -Name DockerMSFTProvider -Force
通过Find-Package docker
确认是否安装成功
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.
安装Docker
Install-Package -Name Docker -Source DockerDefault
启用Docker Linux Container Support
目前基于Windows Container只能运行Windows应用程序。
# 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 here
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
选择一种容器类型,参考如下
docker run --platform=linux --name redis-server -d -p 6379:6379 --restart=always redis
References
- Posted on February 12, 2019 by Ben Thomas,Getting started with Linux Containers on Windows Server 2019
- November 16, 2018 by Andy Syrewicze (Chief Editor)
,How to Run 🐧 Linux Containers on Windows Server 2019 - posted @ 2017-02-10 11:40 北京的201个蓝天,Windows Container 和 Docker:你需要知道的5件事
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· 周边上新:园子的第一款马克杯温暖上架
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
· 使用C#创建一个MCP客户端