文章目录[隐藏]
Win10 系统上安装 Docker 已经很方便了,也可以随时在 Linux 模式或者 Windows 模式间切换,但是在 Server 系统上就没那么友好了,目前官方渠道 Windows Server 2016 上还是只能运行 Windows Container,也就导致并不能运行 Linux 镜像,那么怎么切换成 Linux 模式呢?
准备
首先需要一台正常安装 Win10 的 Docker 机器,然后按下面步骤操作:
- 将 Win10 上的 C:\program files\Docker 目录拷贝到 Server 上的 C:\program files 目录里
- Server 上安装 Hyper-V 支持,界面或者命令行都可以,具体过程略
- 新建注册表文件 docker.reg 内容如下:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Docker Inc.]
[HKEY_LOCAL_MACHINE\SOFTWARE\Docker Inc.\Docker]
[HKEY_LOCAL_MACHINE\SOFTWARE\Docker Inc.\Docker\1.0]
AppPath=C:\\Program Files\\Docker\\Docker for Windows.exe
BinPath=C:\\Program Files\\Docker\\resources\bin
[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=Run Docker for Windows backend service
运行注册表文件导入到 Server 里
- 重启机器并运行
C:\program files\docker\docker\resources\mobylinuxvm.ps1 -create
All Done !
至此 docker linux container 已经可以运行了。如果需要自动启动可以再添加个定时任务或者服务,在官方提供合法方式前只能通过这种方式凑合用了。
发表回复