尝试使用Install-Module在Windows Server 2016中安装Docker时出错

pvcm50d1  于 2023-08-07  发布在  Windows
关注(0)|答案(7)|浏览(208)

我尝试在Windows Server 2016中安装Docker,但没有成功:

PS C:\Windows\system32> Install-Module -Name "DockerMsftProvider" -Force -Verbose
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2/' and PackageManagementProvider is
'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='DockerMsftProvider'' for
 ''.
VERBOSE: Total package yield:'1' for the specified package 'DockerMsftProvider'.
VERBOSE: Performing the operation "Install-Module" on target "Version '1.0.0.1' of module 'DockerMsftProvider'".
VERBOSE: The installation scope is specified to be 'AllUsers'.
VERBOSE: The specified module will be installed in 'C:\Program Files\WindowsPowerShell\Modules'.
VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'.
VERBOSE: Downloading module 'DockerMsftProvider' with version '1.0.0.1' from the repository
'https://www.powershellgallery.com/api/v2/'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='DockerMsftProvider'' for
 ''.
VERBOSE: InstallPackage' - name='DockerMsftProvider',
version='1.0.0.1',destination='C:\Users\x\AppData\Local\Temp\1514242672'
VERBOSE: DownloadPackage' - name='DockerMsftProvider',
version='1.0.0.1',destination='C:\Users\x\AppData\Local\Temp\1514242672\DockerMsftProvider\DockerMsftProvider.nup
kg', uri='https://www.powershellgallery.com/api/v2/package/DockerMsftProvider/1.0.0.1'
VERBOSE: Downloading 'https://www.powershellgallery.com/api/v2/package/DockerMsftProvider/1.0.0.1'.
VERBOSE: An error occurred while sending the request.
VERBOSE: Retry downloading 'https://www.powershellgallery.com/api/v2/package/DockerMsftProvider/1.0.0.1' for '2' more
times
VERBOSE: An error occurred while sending the request.
VERBOSE: Retry downloading 'https://www.powershellgallery.com/api/v2/package/DockerMsftProvider/1.0.0.1' for '1' more
times
VERBOSE: An error occurred while sending the request.
VERBOSE: Retry downloading 'https://www.powershellgallery.com/api/v2/package/DockerMsftProvider/1.0.0.1' for '0' more
times
VERBOSE: Downloading package 'DockerMsftProvider' failed, please make sure
'https://www.powershellgallery.com/api/v2/package/DockerMsftProvider/1.0.0.1' is accessable.
WARNING: Source Location 'https://www.powershellgallery.com/api/v2/package/DockerMsftProvider/1.0.0.1' is not valid.
PackageManagement\Install-Package : Package 'DockerMsftProvider' failed to download.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.1.3.1\PSModule.psm1:1827 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (C:\Users\943397...tProvider.nupkg:String) [Install-Package], Excep
   tion
    + FullyQualifiedErrorId : PackageFailedInstallOrDownload,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPac
   kage

字符串
当我试图通过IE访问URL时,它看起来很迷人,我在公司代理和防火墙后面,没有任何网络配置。
编辑:使用这个我解决了错误,但得到另一个

netsh winhttp import proxy source=ie
$webclient=New-Object System.Net.WebClient
$creds=Get-Credential
$webclient.Proxy.Credentials=$creds


现在我得到:

PS C:\Windows\system32> Find-Package –providerName DockerMsftProvider
WARNING: Cannot find path 'C:\Users\x\AppData\Local\Temp\DockerMsftProvider\DockerDefault_DockerSearchIndex.json'
 because it does not exist.
WARNING: Save-HTTPItem: Bits Transfer failed. Job State: BG_JOB_STATE_ERROR ExitCode = 0


有什么建议吗
编辑2:伙计们,设置环境变量HTTP_PROXY和HTTPS_PROXY对我来说很有效https://docs.docker.com/engine/admin/systemd/#httphttps-proxy

xtupzzrd

xtupzzrd1#

我尝试了以上所有的解决方案,但我不能得到它的工作,直到我运行这个命令

set-executionpolicy unrestricted

字符串
最后,以下步骤对我起了作用:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
 
set-executionpolicy unrestricted
 
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force

Install-Module -Name DockerMsftProvider -Force

Install-Package -Name docker -ProviderName DockerMsftProvider -Force
Restart-Computer -Forc

wqnecbli

wqnecbli2#

这很经典。在执行Invoke-WebRequest https://www.powershellgallery.com/api/v2/package/DockerMsftProvider/1.0.0.1之后,我立即看到了这个问题:Invoke-WebRequest : The request was aborted: Could not create SSL/TLS secure channel的值。
我猜他们开始强制执行SSL/TLS v1.2。
在仍然默认不使用TLS1.2的机器上,在同一会话中运行以下命令:[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
在此之后,像Install-Module -Name "DockerMsftProvider" -Force -Verbose这样的命令应该可以正常工作。

yeotifhr

yeotifhr3#

在PowerShell中以管理员身份尝试以下命令
1.[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

  1. Install-PackageProvider -Name NuGet
    1.安装模块DockerMsftProvider -Force
    1.安装包Docker -ProviderName DockerMsftProvider -Force
1tu0hz3e

1tu0hz3e4#

您可能想尝试手动安装。

erhoui1w

erhoui1w5#

我尝试了下面的步骤来完成。

Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force

Install-Module -Name DockerMsftProvider -Force

Install-Package -Name docker -ProviderName DockerMsftProvider -Force

Restart-Computer -Force

字符串

rkue9o1l

rkue9o1l6#

上面的解决方案对我来说都不起作用,因为DockerMsftProvider已被弃用。
我最终使用chocolatey来安装docker,因为进程不允许机器在处理过程中重新启动。
使用choco install docker在Windows Server 2016机器上安装docker。
相关链接:

bfrts1fy

bfrts1fy7#

是。DockerMsftProvider已弃用。这是一个新的指南https://learn.microsoft.com/en-us/virtualization/windowscontainers/quick-start/set-up-environment?tabs=dockerce#windows-server-1

相关问题