警告:无法找到模块存储库

时间:2017-04-10 12:26:08

标签: docker windows-server-2016

我尝试在激活的Windows Server 2016标准上安装Docker。 我执行“Install-Module -Name DockerMsftProvider -Repository PSGallery -Force”但失败了。它建议找不到PSGallery。我执行了"Get-PSRepository"。 错误:

  

警告:无法找到模块存储库

我用谷歌搜索了3种方法来解决它,但是没有用。

  1. 我成功执行了Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Verbose -Force

  2. 我成功安装了巧克力。

  3. 我执行"powershell Register-PSRepository -Name "PSGallery" –SourceLocation "https://www.powershellgallery.com/api/v2/" -InstallationPolicy Trusted"但失败了。它要我使用"Register-PSRepository -Default"

  4. 我试过"powershell Register-PSRepository -Default -Name "PSGallery" –SourceLocation "https://www.powershellgallery.com/api/v2/" -InstallationPolicy Trusted"但仍然失败了。 我怎么能解决这个问题?

5 个答案:

答案 0 :(得分:24)

使用the deprecation of TLS 1.0 and 1.1 for PowerShell Gallery as of April 2020,cmdlet Update-Module和Install-Module损坏。因此,according to this article需要执行一些命令以使它们重新生效:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 
Install-Module PowerShellGet -RequiredVersion 2.2.4 -SkipPublisherCheck

如果仍然不起作用,请运行以下命令:

[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
Register-PSRepository -Default -Verbose
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted

TLS 1.0和1.1最近在NuGet.org也被弃用: nuget.org deprecated TLS 1.0 and 1.1 但是that was also previously announced

答案 1 :(得分:3)

简单地运行Register-PSRepository -Default(没有任何其他参数)对我有效。之后,Gallery成功注册:

PS C:\Windows\system32> Get-PSRepository

Name                      InstallationPolicy   SourceLocation
----                      ------------------   --------------
PSGallery                 Untrusted            https://www.powershellgallery.com/api/v2/

答案 2 :(得分:1)

我的问题是缺少代理配置

评论的最佳解决方案: https://www.zerrouki.com/working-behind-a-proxy/
感谢@Vadzim

在PowerShell中打开个人资料

PS> notepad $PROFILE

这将打开记事本与您的个人资料设置,将创建不存在。
然后添加:

[system.net.webrequest]::defaultwebproxy = new-object system.net.webproxy('http://webproxy.yourCompany.com:PORT')
[system.net.webrequest]::defaultwebproxy.credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
[system.net.webrequest]::defaultwebproxy.BypassProxyOnLocal = $true

某种程度上我的本地代理设置但不起作用。 以后与Docker相同的问题,=>

> PS> [Environment]::SetEnvironmentVariable("HTTP_PROXY", http://username:password@proxy:port/", [EnvironmentVariableTarget]::Machine)

然后重启docker service

答案 3 :(得分:0)

我收到了类似的消息。我运行了“ Register-PSRepository -default”,它注册成功。然后,我运行了Set-PSRepository -Name PSGallery -InstallationPolicy Trusted。我没有合并命令,但确实有效。

我花了一个多小时试图将凭据传递给代理,就像我对Exchange Online所做的一样,但是没有爱。我断开了连接,改用了客人的WiFi。

答案 4 :(得分:0)

还有一件没有提到的事情。 你确实需要运行

notepad $profile

并复制粘贴此位更改您的代理详细信息:

[system.net.webrequest]::defaultwebproxy = new-object system.net.webproxy('http://webproxy.yourCompany.com:PORT')
[system.net.webrequest]::defaultwebproxy.credentials =  System.Net.CredentialCache]::DefaultNetworkCredentials
[system.net.webrequest]::defaultwebproxy.BypassProxyOnLocal = $true

但如果您开启了 HTTPS 检查,您可能需要将中间人证书添加到 "Trusted Root Certification Authorities"