如何在Windows Server 2016上运行Linux Docker容器?使用Docker for Windows在Windows 10中很容易做到。唯一的方法是安装Docker工具箱并完全忽略内置容器功能吗?
如何在Windows Server 2016上运行Linux Docker容器?使用Docker for Windows在Windows 10中很容易做到。唯一的方法是安装Docker工具箱并完全忽略内置容器功能吗?
在W2016上使用Linux容器是可能的,但需要一些技巧。用户“Algore”在这里描述了它,但我当然已经将其复制到这个答案中。
下载“Docker for Windows”:https://docs.docker.com/docker-for-windows/
在Windows 10 Pro上安装“Docker for Windows”。
将Windows 10机器上的C:\Program Files\Docker
复制到您的Server 2016盒子上的C:\Program Files
。
在W2016盒子上运行install-windowsfeature hyper-v,containers
将这些注册表项复制到文件并在Server 2016盒子上导入它们(reg import):
---START---
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\DockerService]
"EventMessageFile"=hex(2):43,00,3a,00,5c,00,57,00,69,00,6e,00,64,00,6f,00,77,\
00,73,00,5c,00,4d,00,69,00,63,00,72,00,6f,00,73,00,6f,00,66,00,74,00,2e,00,\
4e,00,45,00,54,00,5c,00,46,00,72,00,61,00,6d,00,65,00,77,00,6f,00,72,00,6b,\
00,36,00,34,00,5c,00,76,00,34,00,2e,00,30,00,2e,00,33,00,30,00,33,00,31,00,\
39,00,5c,00,45,00,76,00,65,00,6e,00,74,00,4c,00,6f,00,67,00,4d,00,65,00,73,\
00,73,00,61,00,67,00,65,00,73,00,2e,00,64,00,6c,00,6c,00,00,00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\com.docker.service]
"Type"=dword:00000010
"Start"=dword:00000002
"ErrorControl"=dword:00000000
"ImagePath"=hex(2):22,00,43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,\
6d,00,20,00,46,00,69,00,6c,00,65,00,73,00,5c,00,44,00,6f,00,63,00,6b,00,65,\
00,72,00,5c,00,44,00,6f,00,63,00,6b,00,65,00,72,00,5c,00,63,00,6f,00,6d,00,\
2e,00,64,00,6f,00,63,00,6b,00,65,00,72,00,2e,00,73,00,65,00,72,00,76,00,69,\
00,63,00,65,00,22,00,00,00
"DisplayName"="Docker for Windows Service"
"ObjectName"="LocalSystem"
"Description"="运行 Docker for Windows 后端服务"
---END---
https://docker-saigon.github.io/post/Docker-Beta/
https://jpetazzo.github.io/2013/10/16/configure-docker-bridge-network/
C:\Program Files\Docker\Docker for Windows.exe
之前,确保 Docker 服务 com.docker.service
(start-service com.docker.service
)正在运行。如果您在 Server Core 上运行且没有托盘图标,在启动后出现通知时,单击“更改隐私设置”以进入设置(或修改 programdata 中的 json 文件)。
如果在尝试构建和重建时遇到问题,请查看 C:\Program Files\Docker\Docker\Resources\forceremovedocker.ps1
文件以获取要删除的设置的位置,例如在 C:\programdata
中。我建议不要运行该脚本,因为它会删除所有与 Docker 相关的内容。只需使用其中的部分即可。
Create a Linux Docker machine in Hyper-V
If you want to try out multi architecture you also use docker-machine to create a Linux Docker Engine running in Hyper-V. I have prepared a script that will set up everything as there are some known issues.
C:\vagrant\scripts\create-hyperv-linux-docker-machine.ps1
This PowerShell script creates a Docker machine and updates Docker Engine to the latest so that the Windows Docker client is able to communicate with the Linux Docker Engine.
Use the Linux Docker machine
Open a PowerShell terminal as an administrator and select the Linux Docker machine with
docker-machine env --shell powershell | iex
Now run your first busybox container with
docker run -it busybox uname -a
只需在 Windows Server 2016 上下载并安装 Docker https://www.docker.com/docker-windows
如果您使用 Hyper-V 将 Windows Server 2016 运行为虚拟机,请确保查看此 MS 文档 https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/user-guide/nested-virtualization