Windows Server 2019上的Docker安装失败

von4xj4u  于 2023-04-05  发布在  Docker
关注(0)|答案(2)|浏览(1456)

我正在尝试在Windows Server 2019上安装Docker(* 不是 * Docker Desktop-它在Windows Server上不起作用;我们已经尝试过了).我遵循这个指南:https://blog.sixeyed.com/getting-started-with-docker-on-windows-server-2019/。我在升级的PowerShell窗口中运行以下内容(并使用本地管理员帐户登录)

Install-Module -Name DockerMsftProvider -Repository PSGallery -Force

这部分成功了,所以我进入下一步:

Install-Package -Name docker -ProviderName DockerMsftProvider -verbose

出现以下错误:

> VERBOSE: Using the provider 'DockerMsftProvider' for searching
> packages. WARNING: Cannot find path
> 'C:\Users\ADMINI~1\AppData\Local\Temp\4\DockerMsftProvider\DockerDefault_DockerSearchIndex.json'
> because it does not exist. WARNING: Cannot bind argument to parameter
> 'downloadURL' because it is an empty string. WARNING: The property
> 'AbsoluteUri' cannot be found on this object. Verify that the property
> exists. WARNING: The property 'RequestMessage' cannot be found on this
> object. Verify that the property exists. Install-Package : No match
> was found for the specified search criteria and package name 'docker'.
> Try Get-PackageSource to see all available registered package sources.
> At line:1 char:1
> + Install-Package -Name docker -ProviderName DockerMsftProvider -verbos ...
> + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>     + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package],
> Ex    ception
>     + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

我已经阅读了几个关于此错误的论坛,所以我也尝试过:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-PackageProvider -Name NuGet
Install-Module DockerMsftProvider -Force
Install-Package Docker -ProviderName DockerMsftProvider -Force

...但我收到以下错误:

WARNING: Cannot find path
'C:\Users\ADMINI~1\AppData\Local\Temp\4\DockerMsftProvider\DockerDefault_DockerSearchIndex.json' because it does not
exist.
WARNING: Cannot bind argument to parameter 'downloadURL' because it is an empty string.
WARNING: The property 'AbsoluteUri' cannot be found on this object. Verify that the property exists.
WARNING: The property 'RequestMessage' cannot be found on this object. Verify that the property exists.
Install-Package : No match was found for the specified search criteria and package name 'Docker'. Try Get-PackageSource
to see all available registered package sources.
At line:1 char:1
+ Install-Package Docker -ProviderName DockerMsftProvider -Force
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exc
   eption
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

我读过的关于这个问题的大多数论坛都与代理问题有关,但是虚拟机并不在代理后面--只是一个思科防火墙--Windows Defender防火墙被完全禁用。
我验证了已经安装了容器功能以及Hyper-V。由于机器是虚拟机,因此我还在VMware中启用了“将硬件辅助虚拟化暴露给访客操作系统”和“启用虚拟化CPU性能计数器”。

o7jaxewo

o7jaxewo1#

这个问题显然与Windows注册表中的密码有关。运行Get-PackageSource后,IsTrusted for DockerDefault为False。因此我们运行IIS Crypto CLI(在CMD中:.\iiscryptocli. exe/template default /reboot)将Windows加密注册表项重置为默认值,重新启动后,Docker安装成功。因此,我猜测PowerShell Install-package cmdlet无法从https://go.microsoft.com/fwlink/?LinkID=825636&clcid=0x409获取帮助安装Docker所需的JSON文件,因为存在加密协商问题。

xkrw2x1b

xkrw2x1b2#

我知道这个线程现在已经很老了,但我在Windows Server 2019上也遇到过同样的问题。由于服务器是新的,所以没有第一个答案中描述的密码问题(我已经尝试过了)。
因此,我将DockerMsftIndex.json下载到丢失的文件中:

Invoke-WebRequest -Uri "https://dockermsft.azureedge.net/dockercontainer/DockerMsftIndex.json" `
                  -OutFile $env:USERPROFILE\AppData\Local\Temp\DockerMsftProvider\DockerDefault_DockerSearchIndex.json

不幸的是,DockerMsftProvider在尝试再次安装Docker时删除了该文件。
您只需将文件标记为只读:

(Get-Item $env:USERPROFILE\AppData\Local\Temp\DockerMsftProvider\DockerDefault_DockerSearchIndex.json).Attributes = [IO.FileAttributes]::ReadOnly

和tada:)安装包cmdlet终于接受工作(尽管出现404错误,但Docker已正确安装-不要忘记重新启动服务器)。
但是,这种安装方法似乎不再受支持,因为Docker EE现在有来自Mirantis的付费支持(您可以以这种方式安装的最后版本是20.10.9),See here for Docker CE or containerd installs
希望这对你有帮助:)

相关问题