简体   繁体   English

无法在 docker 容器中使用 chcolatey 安装软件包

[英]Not able to install packages using chcolatey in docker container

I am building a windows container with following software installed我正在构建一个安装了以下软件的 Windows 容器

  1. Notepad++记事本++
  2. MariaDB玛丽亚数据库
  3. HeidiSQL海蒂SQL
  4. .NET Framework 2.0 and 3.5 .NET 框架 2.0 和 3.5

This is the docker image I created.这是我创建的docker镜像。 https://hub.docker.com/repository/docker/mhhaji/winserver2016_base https://hub.docker.com/repository/docker/mh​​haji/winserver2016_base

What I tried :我试过的:

Steps to run the container运行容器的步骤

docker run --name mycontainer mhhaji/winserver2016_base:v1 ping -t localhost

docker exec -it mycontainer powershell

Once powershell is running, I execute the following commands一旦powershell运行,我执行以下命令

Get-PackageProvider
#Chocolatey is not existing so I install chocolatey
Find-Package -Provider chocolatey
#Enter [Y] when prompted
#Install notepad++
Find-Package -Provider chocolatey -name notepad*

I get the following error我收到以下错误

PS C:\> Find-Package -Provider chocolatey -name notepad* 
WARNING: NuGet: The request was aborted: Could not create SSL/TLS secure channel. 

PS C:\> Find-Package -Provider chocolatey -name mariadb 
Find-Package : No match was found for the specified search criteria and package name 'mariadb' as registered package sources. 
At line:1 char:1 
+ Find-Package -Provider chocolatey -name mariadb 
    + Categorylnfo : ObjectNotFound: (Microsoft.Power...ets.FindPackage:FindPac
    + FullyQualifiedErrorld : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManage 

PS C:\> Get-PackageSource 
Name          ProviderName    IsTrusted    Location   
chocolatey    Chocolatey      False        http://chocolatey.org/api/v
PSGallery     PowerShellGet   False        https://www.powershellgalle   


PS C:\> Get-PackageParameters
Get-PackageParameters : The term 'Get-PackageParameters' is not recognized as the name 
o program. Check the spelling of the name, or if a path was included, verify that the path 
At line:1 char:1 
+ Get-PackageParameters 
    + Categorylnfo : ObjectNotFound: (Get-PackageParameters:String) [], Command 
    + FullyQualifiedErrorld : CommandNotFoundException 

PS C:\> Get-PackageProvider 
Name           Version         DynamicOptions 
Chocolatey     2.8.5.130       SkipDependencies, ContinueOnFailure, 
ExcludeVersion,ForceX86, PackageSaveMode, FilterOnTag, Contains, 
AllowPrereleaseVersions, Conf  
msi            3.0.0.0         AdditionalArguments  
msu            3.0.0.0 
PowerShellGet  1.0.0.1         PackageManagementProvider, Type, Scope, AllowClobber,SkipPublisherCheck, InstallUpdate, NoPathUpdate, Filter, Tag, Includes, DscRes
Programs       3.0.0.0         IncludeWindowsInstaller, IncludeSystemComponent

I was able to download chocolatey so connecting to external endpoints doesnt seem to be a problem.我能够下载 Chocolatey,因此连接到外部端点似乎不是问题。

Update: Seems like nuget is not installed in my image.更新:我的图像中似乎没有安装 nuget。 Looking for solution but not able to find.正在寻找解决方案,但无法找到。

Make sure your system is able to support TLS 1.2 as that is necessary for chocolatey to run确保您的系统能够支持 TLS 1.2,因为这是巧克力运行所必需的

PS> [Enum]::GetNames([Net.SecurityProtocolType]) -contains 'Tls12'

Enable TLS 1.2 for your system为您的系统启用 TLS 1.2

PS> [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12

Finally install chocolatey directly from source最后直接从源码安装 Chocolatey

PS> iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM