我在Windows上使用Docker,当我试图用这个命令拉一个PHP图像时

$ docker pull php

我收到了这样的信息:

Using default tag: latest
latest: Pulling from library/php no matching manifest for windows/amd64 
        in the manifest list entries

我该如何解决这个问题?


当前回答

我在开始学习docker时遇到过这个错误,我对这个场景的理解如下:

为什么你提到这个问题: 因为你引用的是基于Linux的镜像,而你目前使用的是基于windows的平台来运行/构建docker镜像。

解决方法: 简单的回答:要么将当前平台切换到Linux模式,要么拉出基于windows的映像。 以下是可能的选项:

切换到Linux容器,因为错误是“没有匹配清单for windows/amd64” 设置docker环境为“experimental”:true。 提取特定于平台的图像 例如:docker pull——platform {linux/Windows} {image-name}

其他回答

更新为Windows 10 20H2

转到Docker配置 进入Docker Engine选项卡 将行“experimental”:false更改为“experimental”:true 使用应用&重启按钮重新启动Docker


你也可以手动修改配置文件,用你最喜欢的代码编辑器打开它(可视代码,notepad++…),例如:

# BACKUP Your file with PowerShell
Copy-Item -Path C:\ProgramData\Docker\config\daemon.json -Destination C:\ProgramData\Docker\config\daemon.json.backup

# Open the file with Visual Code
code C:\ProgramData\Docker\config\daemon.json

或者直接用Powershell更改字符串

# Set Path in variable
$FILE = "C:\ProgramData\Docker\config\daemon.json"

# Replace '"experimental": false' to '"experimental": true'
(Get-Content -Path $FILE) -replace '"experimental": false','"experimental": true' | Set-Content -Path $FILE

# Check the file content
type $FILE

输出示例

PS C:\WINDOWS\system32> type $FILE
{
  "registry-mirrors": [],
  "insecure-registries": [],
  "debug": false,
  "experimental": true
}

在您需要重新启动Docker守护进程后

PS C:\WINDOWS\system32> Restart-Service docker

检查服务状态

PS C:\WINDOWS\system32> Get-Service docker
Status   Name               DisplayName
------   ----               -----------
Running  docker             Docker Engine

在Windows上,必须编辑文件守护进程。Json或windows-daemon-options。在Windows上,配置文件的默认位置是%programdata%\docker\config\daemon。Json或%programdata%\docker\resources\windows-daemon-options.json

json文件上的可选字段特性,允许用户启用或禁用特定的守护进程特性。示例:{" features":{"buildkit": true}}启用buildkit作为默认的docker映像构建器。

版本:Windows 10

步骤1:右键单击Docker实例并进入设置

步骤2:基本到高级,并设置“实验”:true

步骤3:重启Docker

步骤4:安装dockerfile成功(例如:docker build -t williehao/cheers2019)

确保您没有尝试使用Linux/WSL来提取Windows映像。

请使用Powershell终端。

造成这个错误的原因可能有很多。但是导致这个错误最明显的原因是在Linux容器模式下使用Windows容器,反之亦然。

单击上下文菜单中的系统托盘中的Docker图标 点击“切换到Window/Linux容器” 选项单击“切换对话框”中的“切换按钮” 这可能花不了多少时间 确保Docker现在处于运行状态