Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install powershell modules within a docker container off the mcr.microsoft.com/powershell image?

Please, observe:

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 />

So, there is no PS repositories. OK, I run Register-PSRepository -Default - it does not fail. But it also does nothing - I still have no PS repositories.

Other people have the same issue, but I did not understand how they resolved it. What blows my mind is that it is microsoft's powershell image that does not work.

What am I missing?

EDIT 1

Please, allow me to clarify the acceptance criteria for an answer. If your answer shows how one can run docker run -it mcr.microsoft.com/powershell pwsh and then Get-PSRepository - you hit the mark and get the points.

like image 385
mark Avatar asked Feb 01 '20 00:02

mark


People also ask

Which of the PowerShell commands are used to install the Docker?

Run the following PowerShell commands as administrator. Once the installation of DockerMsftProvider is complete, Use the Install-Package cmdlet with the following syntax to install Docker. Important: The provider enables the containers feature on your Server.


1 Answers

The answer for me seems to be to run this after I connect to VPN

Get-NetIPInterface -InterfaceAlias "vEthernet (WSL)" | Set-NetIPInterface -InterfaceMetric 1
Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 6000

I found this at https://sysblog.dk/?p=254

If you would like to "set it and forget it", follow these instructions for setting up a scheduled task trigger.

like image 68
Doug Moore Avatar answered Oct 03 '22 02:10

Doug Moore