请注意:
C:\> docker run -it mcr.microsoft.com/powershell pwsh
PowerShell 6.2.4
Copyright (c) Microsoft Corporation. All rights reserved.
https://aka.ms/pscore6-docs
Type 'help' to get help.
PS /> Get-PSRepository
WARNING: Unable to find module repositories.
PS /> Get-PackageProvider
Name Version DynamicOptions
---- ------- --------------
NuGet 3.0.0.1 Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Contains, AllowPrereleaseVersions, ConfigFile, SkipVali…
PowerShellGet 2.1.3.0 PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, InstallUpdate, NoPathUpdate, AllowPrereleaseVersions, Fil…
PS /> Register-PSRepository -Default
PS /> Get-PSRepository
WARNING: Unable to find module repositories.
PS /> $env:PSModulePath
/root/.local/share/powershell/Modules:/usr/local/share/powershell/Modules:/opt/microsoft/powershell/6/Modules
PS />
因此,没有PS存储库。 OK,我运行Register-PSRepository -Default
-它不会失败。但这也无能为力-我仍然没有PS储存库。
其他人也有同样的问题,但是我不明白他们是如何解决的。令我震惊的是,Microsoft的powershell映像不起作用。
我想念什么?
编辑1
请允许我澄清答案的接受标准。如果您的答案显示了如何运行docker run -it mcr.microsoft.com/powershell pwsh
,然后运行Get-PSRepository
-您就打出分数并获得分数。
答案 0 :(得分:3)
我的答案似乎是在我连接到 VPN 后运行它
Get-NetIPInterface -InterfaceAlias "vEthernet (WSL)" | Set-NetIPInterface -InterfaceMetric 1
Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 6000
找到了这个
如果您想“设置并忘记它”,请按照these instructions设置计划任务触发器。
答案 1 :(得分:0)
我遇到了同样的问题,问题在于该容器已连接到Internet,但未找到DNS地址。如果您运行ping google.com
而无法正常工作,则会遇到类似的问题。
解决方法是按照以下说明在Docker JSON配置文件中设置"dns": ["1.1.1.1"]
:Not able to access internet inside docker windows container
答案 2 :(得分:0)
我认为在Linux中这不是重点,因为:
$ docker run -it mcr.microsoft.com/powershell bash
root@a92d3c657304:/# apt -qq update; apt install -qq -y iputils-ping
root@a92d3c657304:/# ping www.google.com
PING www.google.com (216.58.215.228) 56(84) bytes of data.
64 bytes from zrh11s02-in-f4.1e100.net (216.58.215.228): icmp_seq=1 ttl=111 time=6.01 ms
64 bytes from zrh11s02-in-f4.1e100.net (216.58.215.228): icmp_seq=2 ttl=111 time=6.04 ms
64 bytes from zrh11s02-in-f4.1e100.net (216.58.215.228): icmp_seq=3 ttl=111 time=5.49 ms