如何在 Windows Server 2016 上运行 Linux Docker 容器?

如何在 Windows Server 2016 上运行 Linux Docker 容器?

我得到:

PS C:\tmp> docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
no matching manifest for windows/amd64 in the manifest list entries

现在,在你说“复制!”,“确保它处于实验模式”之前,就像这个问题的所有其他答案一样,我

我已按照基于 LinuxKit 的 LCOW 镜像,甚至阅读并按照步骤手动创建 hyper-v 映像在 Windows 上运行 Linux 容器

我已经下载了 Docker 的夜间版本。

我正在实验模式下运行:

PS C:\tmp> docker version
Client:
 Version:       master-dockerproject-2018-02-01
 API version:   1.36
 Go version:    go1.9.3
 Git commit:    26a2a459
 Built: Thu Feb  1 23:50:28 2018
 OS/Arch:       windows/amd64
 Experimental:  false
 Orchestrator:  swarm

Server:
 Engine:
  Version:      master-dockerproject-2018-02-01
  API version:  1.36 (minimum version 1.24)
  Go version:   go1.9.3
  Git commit:   53a58da
  Built:        Thu Feb  1 23:57:33 2018
  OS/Arch:      windows/amd64
  Experimental: true

我曾尝试过这样的--platform论点:

PS C:\tmp> docker run --platform linux ubuntu
Unable to find image 'ubuntu:latest' locally
C:\Program Files\Docker\docker.exe: Error response from daemon: invalid platform: invalid platform os "linux".
See 'C:\Program Files\Docker\docker.exe run --help'.

我似乎与docker info我的 Windows 10 台式机有一些不同,在 Windows 10 台式机上一切正常:

Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: master-dockerproject-2018-02-01
Storage Driver: windowsfilter
 Windows:
Logging Driver: json-file
Plugins:
 Volume: local
 Network: ics l2bridge l2tunnel nat null overlay transparent
 Log: awslogs etwlogs fluentd gelf json-file logentries splunk syslog
Swarm: inactive
Default Isolation: process

# Windows 10 value:
# Kernel Version: 4.9.60-linuxkit-aufs
Kernel Version: 10.0 14393 (14393.2007.amd64fre.rs1_release.171231-1800)

# Windows 10 values:
# Operating System: Docker for Windows
# OSType: linux
Operating System: Windows Server 2016 Standard
OSType: windows

Architecture: x86_64
CPUs: 2
Total Memory: 3.997GiB
Name: Tests
ID: ...
Docker Root Dir: C:\lcow
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: -1
 Goroutines: 16
 System Time: 2018-02-02T14:46:53.5608784+08:00
 EventsListeners: 0
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

因此 Windows 服务器上的版本未配置为 Linux 容器。

我如何改变该配置是否正确?

在 Windows 版 Docker 上,您可以方便地右键单击任务栏中的图标并选择切换到 Linux 容器

在 Windows Server 上您怎样才能完成该任务?

答案1

看来您没有在 Windows Server 版本 1709 上运行。您的 Windows 内核版本是

Kernel Version: 10.0 14393 (14393.2007.amd64fre.rs1_release.171231-1800)

而 1709 的内核版本

Kernel Version: 10.0 16299 (16299.15.amd64fre.rs3_release.170928-1534)

1709 仅提供 Server Core 安装。它没有桌面环境。因此您无法在其上安装适用于 Windows 的 Docker。

根据https://blog.docker.com/2017/09/preview-linux-containers-on-windows/。因此您必须在 1709 上尝试此功能。

当它在1709上运行时,docker info 显示以下内容:

C:\Users\temp>docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 3
Server Version: master-dockerproject-2018-02-10
Storage Driver: windowsfilter (windows) lcow (linux)
 Windows:
 LCOW:
Logging Driver: json-file
Plugins:
 Volume: local
 Network: ics l2bridge l2tunnel nat null overlay transparent
 Log: awslogs etwlogs fluentd gelf json-file logentries splunk syslog
Swarm: inactive
Default Isolation: process
Kernel Version: 10.0 16299 (16299.15.amd64fre.rs3_release.170928-1534)
Operating System: Windows Server Datacenter
OSType: windows
Architecture: x86_64
CPUs: 4
Total Memory: 16GiB
Name: winsvr1709
ID: W4MK:WLAQ:3NCM:4TUT:CNKP:NPWC:B6TJ:VSC5:LKGU:LT4F:ZEAH:22X3
Docker Root Dir: C:\ProgramData\docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

有关如何在 Windows Server 上运行 Linux 容器的帖子: https://chunliu.me/2018/02/12/running-linux-containers-on-windows-server-2016/

答案2

您可以尝试从命令行切换环境:

& 'C:\Program Files\Docker\Docker\DockerCli.exe' -SwitchDaemon

相关内容