profile
viewpoint

Ask questionschoco install package failed in docker container

What You Are Seeing?

In my docker container, choco is installed successfully, but doing "choco install 7zip.install" failed. But outside container at windows server 2019, "choco install 7zip.install" works. I tried other packages and also fails, ex : choco install git -y

Error message shows: Elevating permissions and running ["C:\ProgramData\chocolatey\lib\7zip.install\tools\7zip_x64.exe" /S ]. This may take a while, depending on the statements. Command ["C:\ProgramData\chocolatey\lib\7zip.install\tools\7zip_x64.exe" /S ] exited with '-1073741511'. ERROR: Running ["C:\ProgramData\chocolatey\lib\7zip.install\tools\7zip_x64.exe" /S ] was not successful. Exit code was ' -1073741511'. See log for possible error messages.

What is Expected?

choco install should work

How Did You Get This To Happen? (Steps to Reproduce)

I have a Dockerfile, and I execute "docker build . "

Dockerfile below: ARG WIN_VER="ltsc2019" FROM mcr.microsoft.com/windows/servercore:$WIN_VER WORKDIR C:\temp ADD https://chocolatey.org/install.ps1 C:\TEMP\choco-install.ps1 SHELL ["cmd", "/S", "/C"] RUN powershell C:\TEMP\choco-install.ps1 RUN choco install 7zip.install -y RUN choco install msys2 --params "/NoUpdate /InstallDir:C:\msys2" -y

Output Log

  1. login to the container
  2. Install again the 7zip.install with -y -d -v C:\temp>choco install 7zip.install -y -d -v
Chocolatey v0.10.15
Chocolatey is running on Windows v 10.0.17763.0
Attempting to delete file "C:/ProgramData/chocolatey/choco.exe.old".
Attempting to delete file "C:\ProgramData\chocolatey\choco.exe.old".
Command line: "C:\ProgramData\chocolatey\choco.exe" install 7zip.install -y -d -v
Received arguments: install 7zip.install -y -d -v
RemovePendingPackagesTask is now ready and waiting for PreRunMessage.
Sending message 'PreRunMessage' out if there are subscribers...
[Pending] Removing all pending packages that should not be considered installed...
Performing validation checks.
Global Configuration Validation Checks:
 - Package Exit Code / Exit On Reboot = Checked
System State Validation Checks:
 Reboot Requirement Checks:
 - Pending Computer Rename = Checked
 - Pending Component Based Servicing = Checked
 - Pending Windows Auto Update = Checked
 - Pending File Rename Operations = Checked
 - Pending Windows Package Installer = Checked
 - Pending Windows Package Installer SysWow64 = Checked
The source 'https://chocolatey.org/api/v2/' evaluated to a 'normal' source type

NOTE: Hiding sensitive configuration data! Please double and triple
 check to be sure no sensitive data is shown, especially if copying
 output to a gist for review.
Configuration: CommandName='install'|
CacheLocation='C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey'|

ContainsLegacyPackageInstalls='True'|
CommandExecutionTimeoutSeconds='2700'|WebRequestTimeoutSeconds='30'|
Sources='https://chocolatey.org/api/v2/'|SourceType='normal'|
Debug='True'|Verbose='True'|Trace='False'|Force='False'|Noop='False'|
HelpRequested='False'|UnsuccessfulParsing='False'|RegularOutput='True'|
QuietOutput='False'|PromptForConfirmation='False'|AcceptLicense='True'|
AllowUnofficialBuild='False'|Input='7zip.install'|AllVersions='False'|
SkipPackageInstallProvider='False'|PackageNames='7zip.install'|
Prerelease='False'|ForceX86='False'|OverrideArguments='False'|
NotSilent='False'|ApplyPackageParametersToDependencies='False'|
ApplyInstallArgumentsToDependencies='False'|IgnoreDependencies='False'|
AllowMultipleVersions='False'|AllowDowngrade='False'|
ForceDependencies='False'|Information.PlatformType='Windows'|
Information.PlatformVersion='10.0.17763.0'|
Information.PlatformName='Windows Server 2016'|
Information.ChocolateyVersion='0.10.15.0'|
Information.ChocolateyProductVersion='0.10.15'|
Information.FullName='choco, Version=0.10.15.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb'|

Information.Is64BitOperatingSystem='True'|
Information.Is64BitProcess='True'|Information.IsInteractive='False'|
Information.UserName='ContainerAdministrator'|
Information.UserDomainName='User Manager'|
Information.IsUserAdministrator='True'|
Information.IsUserSystemAccount='False'|
Information.IsUserRemoteDesktop='False'|
Information.IsUserRemote='True'|
Information.IsProcessElevated='True'|
Information.IsLicensedVersion='False'|Information.LicenseType='Foss'|
Information.CurrentDirectory='C:\temp'|Features.AutoUninstaller='True'|
Features.ChecksumFiles='True'|Features.AllowEmptyChecksums='False'|
Features.AllowEmptyChecksumsSecure='True'|
Features.FailOnAutoUninstaller='False'|
Features.FailOnStandardError='False'|Features.UsePowerShellHost='True'|
Features.LogEnvironmentValues='False'|Features.LogWithoutColor='False'|
Features.VirusCheck='False'|
Features.FailOnInvalidOrMissingLicense='False'|
Features.IgnoreInvalidOptionsSwitches='True'|
Features.UsePackageExitCodes='True'|
Features.UseEnhancedExitCodes='False'|
Features.UseFipsCompliantChecksums='False'|
Features.ShowNonElevatedWarnings='True'|
Features.ShowDownloadProgress='True'|
Features.StopOnFirstPackageFailure='False'|
Features.UseRememberedArgumentsForUpgrades='False'|
Features.IgnoreUnfoundPackagesOnUpgradeOutdated='False'|
Features.SkipPackageUpgradesWhenNotInstalled='False'|
Features.RemovePackageInformationOnUninstall='False'|
Features.ExitOnRebootDetected='False'|
Features.LogValidationResultsOnWarnings='True'|
Features.UsePackageRepositoryOptimizations='True'|
Features.ScriptsCheckLastExitCode='False'|
ListCommand.LocalOnly='False'|
ListCommand.IdOnly='False'|ListCommand.IncludeRegistryPrograms='False'|
ListCommand.PageSize='25'|ListCommand.Exact='False'|
ListCommand.ByIdOnly='False'|ListCommand.ByTagOnly='False'|
ListCommand.IdStartsWith='False'|ListCommand.OrderByPopularity='False'|
ListCommand.ApprovedOnly='False'|
ListCommand.DownloadCacheAvailable='False'|
ListCommand.NotBroken='False'|
ListCommand.IncludeVersionOverrides='False'|
UpgradeCommand.FailOnUnfound='False'|
UpgradeCommand.FailOnNotInstalled='False'|
UpgradeCommand.NotifyOnlyAvailableUpgrades='False'|
UpgradeCommand.ExcludePrerelease='False'|
NewCommand.AutomaticPackage='False'|
NewCommand.UseOriginalTemplate='False'|SourceCommand.Command='unknown'|
SourceCommand.Priority='0'|SourceCommand.BypassProxy='False'|
SourceCommand.AllowSelfService='False'|
SourceCommand.VisibleToAdminsOnly='False'|
FeatureCommand.Command='unknown'|ConfigCommand.Command='unknown'|
ApiKeyCommand.Remove='False'|PinCommand.Command='unknown'|
OutdatedCommand.IgnorePinned='False'|Proxy.BypassOnLocal='True'|
_ Chocolatey:ChocolateyInstallCommand - Normal Run Mode _
Installing the following packages:
7zip.install
By installing you accept licenses for the packages.
Using 'https://chocolatey.org/api/v2/'.
- Supports prereleases? 'True'.
- Is ServiceBased? 'True'.
Package '7zip.install' found on source 'https://chocolatey.org/api/v2/'
[NuGet] Attempting to resolve dependency 'chocolatey-core.extension (= 1.3.3)'.
Progress: Downloading chocolatey-core.extension 1.3.5.1... 100%
Progress: Downloading 7zip.install 19.0... 100%
[NuGet] Installing 'chocolatey-core.extension 1.3.5.1'.
[NuGet] Added file 'chocolatey-core.psm1' to folder 'chocolatey-core.extension\extensions'.
[NuGet] Added file 'Get-AppInstallLocation.ps1' to folder 'chocolatey-core.extension\extensions'.
[NuGet] Added file 'Get-AvailableDriveLetter.ps1' to folder 'chocolatey-core.extension\extensions'.
[NuGet] Added file 'Get-EffectiveProxy.ps1' to folder 'chocolatey-core.extension\extensions'.
[NuGet] Added file 'Get-PackageCacheLocation.ps1' to folder 'chocolatey-core.extension\extensions'.
[NuGet] Added file 'Get-PackageParameters.ps1' to folder 'chocolatey-core.extension\extensions'.
[NuGet] Added file 'Get-UninstallRegistryKey.ps1' to folder 'chocolatey-core.extension\extensions'.
[NuGet] Added file 'Get-WebContent.ps1' to folder 'chocolatey-core.extension\extensions'.
[NuGet] Added file 'Register-Application.ps1' to folder 'chocolatey-core.extension\extensions'.
[NuGet] Added file 'Remove-Process.ps1' to folder 'chocolatey-core.extension\extensions'.
[NuGet] Added file 'chocolatey-core.extension.nupkg' to folder 'chocolatey-core.extension'.
[NuGet] Added file 'chocolatey-core.extension.nuspec' to folder 'chocolatey-core.extension'.
[NuGet] Successfully installed 'chocolatey-core.extension 1.3.5.1'.

chocolatey-core.extension v1.3.5.1 [Approved]
chocolatey-core.extension package files install completed. Performing other installation steps.
Capturing package files in 'C:\ProgramData\chocolatey\lib\chocolatey-core.extension'
 Found 'C:\ProgramData\chocolatey\lib\chocolatey-core.extension\chocolatey-core.extension.nupkg'
  with checksum '7F066B11D65D07704BDB0A9D8FB4437F'
 Found 'C:\ProgramData\chocolatey\lib\chocolatey-core.extension\chocolatey-core.extension.nuspec'
  with checksum 'D71F7B1D873058AA1A6CE4EA7CD21AE8'
 Found 'C:\ProgramData\chocolatey\lib\chocolatey-core.extension\extensions\chocolatey-core.psm1'
  with checksum '8007E67FDE249548DBF78D1DC8AFDCCC'
 Found 'C:\ProgramData\chocolatey\lib\chocolatey-core.extension\extensions\Get-AppInstallLocation.ps1'
  with checksum 'D036C97BC50A3731BF69A15417F60E72'
 Found 'C:\ProgramData\chocolatey\lib\chocolatey-core.extension\extensions\Get-AvailableDriveLetter.ps1'
  with checksum '2F386746AFC2ACB9561DFB245239B93F'
 Found 'C:\ProgramData\chocolatey\lib\chocolatey-core.extension\extensions\Get-EffectiveProxy.ps1'
  with checksum '3895F062D2D91D9D32D1FC57A619066C'
 Found 'C:\ProgramData\chocolatey\lib\chocolatey-core.extension\extensions\Get-PackageCacheLocation.ps1'
  with checksum '77A378E5C659E5A53D2D64E276159B62'
 Found 'C:\ProgramData\chocolatey\lib\chocolatey-core.extension\extensions\Get-PackageParameters.ps1'
  with checksum 'C08B3AF8CA150B6609DF2B978B693269'
 Found 'C:\ProgramData\chocolatey\lib\chocolatey-core.extension\extensions\Get-UninstallRegistryKey.ps1'
  with checksum '3FAA5C11AAFC4EA35BB98EA797446C97'
 Found 'C:\ProgramData\chocolatey\lib\chocolatey-core.extension\extensions\Get-WebContent.ps1'
  with checksum '57D013E581EFEA3D4D8366183C9A5797'
 Found 'C:\ProgramData\chocolatey\lib\chocolatey-core.extension\extensions\Register-Application.ps1'
  with checksum 'D2853E569DAC9A341642BA76EC4FB411'
 Found 'C:\ProgramData\chocolatey\lib\chocolatey-core.extension\extensions\Remove-Process.ps1'
  with checksum 'CFDFB899BE8491454B264BF7C5EF08BA'
Attempting to create directory "C:\ProgramData\chocolatey\extensions".
Attempting to create directory "C:\ProgramData\chocolatey\extensions\chocolatey-core".
Attempting to copy "C:\ProgramData\chocolatey\lib\chocolatey-core.extension\extensions\chocolatey-core.psm1"
 to "C:\ProgramData\chocolatey\extensions\chocolatey-core\chocolatey-core.psm1".
Attempting to copy "C:\ProgramData\chocolatey\lib\chocolatey-core.extension\extensions\Get-AppInstallLocation.ps1"
 to "C:\ProgramData\chocolatey\extensions\chocolatey-core\Get-AppInstallLocation.ps1".
Attempting to copy "C:\ProgramData\chocolatey\lib\chocolatey-core.extension\extensions\Get-AvailableDriveLetter.ps1"
 to "C:\ProgramData\chocolatey\extensions\chocolatey-core\Get-AvailableDriveLetter.ps1".
Attempting to copy "C:\ProgramData\chocolatey\lib\chocolatey-core.extension\extensions\Get-EffectiveProxy.ps1"
 to "C:\ProgramData\chocolatey\extensions\chocolatey-core\Get-EffectiveProxy.ps1".
Attempting to copy "C:\ProgramData\chocolatey\lib\chocolatey-core.extension\extensions\Get-PackageCacheLocation.ps1"
 to "C:\ProgramData\chocolatey\extensions\chocolatey-core\Get-PackageCacheLocation.ps1".
Attempting to copy "C:\ProgramData\chocolatey\lib\chocolatey-core.extension\extensions\Get-PackageParameters.ps1"
 to "C:\ProgramData\chocolatey\extensions\chocolatey-core\Get-PackageParameters.ps1".
Attempting to copy "C:\ProgramData\chocolatey\lib\chocolatey-core.extension\extensions\Get-UninstallRegistryKey.ps1"
 to "C:\ProgramData\chocolatey\extensions\chocolatey-core\Get-UninstallRegistryKey.ps1".
Attempting to copy "C:\ProgramData\chocolatey\lib\chocolatey-core.extension\extensions\Get-WebContent.ps1"
 to "C:\ProgramData\chocolatey\extensions\chocolatey-core\Get-WebContent.ps1".
Attempting to copy "C:\ProgramData\chocolatey\lib\chocolatey-core.extension\extensions\Register-Application.ps1"
 to "C:\ProgramData\chocolatey\extensions\chocolatey-core\Register-Application.ps1".
Attempting to copy "C:\ProgramData\chocolatey\lib\chocolatey-core.extension\extensions\Remove-Process.ps1"
 to "C:\ProgramData\chocolatey\extensions\chocolatey-core\Remove-Process.ps1".
 Installed/updated chocolatey-core extensions.
Attempting to create directory "C:\ProgramData\chocolatey\.chocolatey".
Adding 'Hidden' attribute(s) to 'C:\ProgramData\chocolatey\.chocolatey'.
Attempting to create directory "C:\ProgramData\chocolatey\.chocolatey\chocolatey-core.extension.1.3.5.1".
There was no original file at 'C:\ProgramData\chocolatey\.chocolatey\chocolatey-core.extension.1.3.5.1\.files'
Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\chocolatey-core.extension.1.3.5.1\.extra".
Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\chocolatey-core.extension.1.3.5.1\.version".
Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\chocolatey-core.extension.1.3.5.1\.sxs".
Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\chocolatey-core.extension.1.3.5.1\.pin".
Sending message 'HandlePackageResultCompletedMessage' out if there are subscribers...
Attempting to delete file "C:\ProgramData\chocolatey\lib\chocolatey-core.extension\.chocolateyPending".
 The install of chocolatey-core.extension was successful.
  Software installed to 'C:\ProgramData\chocolatey\extensions\chocolatey-core'
[NuGet] Installing '7zip.install 19.0'.
[NuGet] Added file 'LICENSE.txt' to folder '7zip.install\legal'.
[NuGet] Added file 'VERIFICATION.txt' to folder '7zip.install\legal'.
[NuGet] Added file '7zip_x32.exe' to folder '7zip.install\tools'.
[NuGet] Added file '7zip_x64.exe' to folder '7zip.install\tools'.
[NuGet] Added file 'chocolateyInstall.ps1' to folder '7zip.install\tools'.
[NuGet] Added file 'chocolateyUninstall.ps1' to folder '7zip.install\tools'.
[NuGet] Added file '7zip.install.nupkg' to folder '7zip.install'.
[NuGet] Added file '7zip.install.nuspec' to folder '7zip.install'.
[NuGet] Successfully installed '7zip.install 19.0'.

7zip.install v19.0 [Approved]
7zip.install package files install completed. Performing other installation steps.
Setting installer args for 7zip.install
Setting package parameters for 7zip.install
Contents of 'C:\ProgramData\chocolatey\lib\7zip.install\tools\chocolateyInstall.ps1':
$ErrorActionPreference = 'Stop'

$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$filePath = if ((Get-OSArchitectureWidth 64) -and $env:chocolateyForceX86 -ne $true) {
       Write-Host "Installing 64 bit version" ; Get-Item $toolsDir\*_x64.exe }
else { Write-Host "Installing 32 bit version" ; Get-Item $toolsDir\*_x32.exe }

$packageArgs = @{
  packageName    = '7zip.install'
  fileType       = 'exe'
  softwareName   = '7-zip*'
  file           = $filePath
  silentArgs     = '/S'
  validExitCodes = @(0)
}
Install-ChocolateyInstallPackage @packageArgs
Remove-Item $toolsDir\*.exe -ea 0 -force

$installLocation = Get-AppInstallLocation $packageArgs.softwareName
if (!$installLocation)  { Write-Warning "Can't find 7zip install location"; return }
Write-Host "7zip installed to '$installLocation'"

Install-BinFile '7z' $installLocation\7z.exe

Calling built-in PowerShell host with ['[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.T
hread]::CurrentThread.CurrentUICulture = ''; & import-module -name 'C:\ProgramData\chocolatey\helpers\chocolateyInstalle
r.psm1'; & 'C:\ProgramData\chocolatey\helpers\chocolateyScriptRunner.ps1' -packageScript 'C:\ProgramData\chocolatey\lib\
7zip.install\tools\chocolateyInstall.ps1' -installArguments '' -packageParameters ''']
Redirecting System.Management.Automation.resources, Version=3.0.0.0, Culture=en-US, PublicKeyToken=31bf3856ad364e35, req
uested by ''
Host version is 5.1.17763.1, PowerShell Version is '5.1.17763.1852' and CLR Version is '4.0.30319.42000'.
VERBOSE: Exporting function 'Format-FileSize'.
VERBOSE: Exporting function 'Get-ChecksumValid'.
VERBOSE: Exporting function 'Get-ChocolateyUnzip'.
VERBOSE: Exporting function 'Get-ChocolateyWebFile'.
VERBOSE: Exporting function 'Get-EnvironmentVariable'.
VERBOSE: Exporting function 'Get-EnvironmentVariableNames'.
VERBOSE: Exporting function 'Get-FtpFile'.
VERBOSE: Exporting function 'Get-OSArchitectureWidth'.
VERBOSE: Exporting function 'Get-PackageParameters'.
VERBOSE: Exporting function 'Get-PackageParametersBuiltIn'.
VERBOSE: Exporting function 'Get-ToolsLocation'.
VERBOSE: Exporting function 'Get-UACEnabled'.
VERBOSE: Exporting function 'Get-UninstallRegistryKey'.
VERBOSE: Exporting function 'Get-VirusCheckValid'.
VERBOSE: Exporting function 'Get-WebFile'.
VERBOSE: Exporting function 'Get-WebFileName'.
VERBOSE: Exporting function 'Get-WebHeaders'.
VERBOSE: Exporting function 'Install-BinFile'.
VERBOSE: Exporting function 'Install-ChocolateyDesktopLink'.
VERBOSE: Exporting function 'Install-ChocolateyEnvironmentVariable'.
VERBOSE: Exporting function 'Install-ChocolateyExplorerMenuItem'.
VERBOSE: Exporting function 'Install-ChocolateyFileAssociation'.
VERBOSE: Exporting function 'Install-ChocolateyInstallPackage'.
VERBOSE: Exporting function 'Install-ChocolateyPackage'.
VERBOSE: Exporting function 'Install-ChocolateyPath'.
VERBOSE: Exporting function 'Install-ChocolateyPinnedTaskBarItem'.
VERBOSE: Exporting function 'Install-ChocolateyPowershellCommand'.
VERBOSE: Exporting function 'Install-ChocolateyShortcut'.
VERBOSE: Exporting function 'Install-ChocolateyVsixPackage'.
VERBOSE: Exporting function 'Install-ChocolateyZipPackage'.
VERBOSE: Exporting function 'Install-Vsix'.
VERBOSE: Exporting function 'Set-EnvironmentVariable'.
VERBOSE: Exporting function 'Set-PowerShellExitCode'.
VERBOSE: Exporting function 'Start-ChocolateyProcessAsAdmin'.
VERBOSE: Exporting function 'Test-ProcessAdminRights'.
VERBOSE: Exporting function 'Uninstall-BinFile'.
VERBOSE: Exporting function 'Uninstall-ChocolateyEnvironmentVariable'.
VERBOSE: Exporting function 'Uninstall-ChocolateyPackage'.
VERBOSE: Exporting function 'Uninstall-ChocolateyZipPackage'.
VERBOSE: Exporting function 'Update-SessionEnvironment'.
VERBOSE: Exporting function 'Write-ChocolateyFailure'.
VERBOSE: Exporting function 'Write-ChocolateySuccess'.
VERBOSE: Exporting function 'Write-FileUpdateLog'.
VERBOSE: Exporting function 'Write-FunctionCallLogMessage'.
VERBOSE: Exporting alias 'Get-ProcessorBits'.
VERBOSE: Exporting alias 'Get-OSBitness'.
VERBOSE: Exporting alias 'Get-InstallRegistryKey'.
VERBOSE: Exporting alias 'Generate-BinFile'.
VERBOSE: Exporting alias 'Add-BinFile'.
VERBOSE: Exporting alias 'Start-ChocolateyProcess'.
VERBOSE: Exporting alias 'Invoke-ChocolateyProcess'.
VERBOSE: Exporting alias 'Remove-BinFile'.
VERBOSE: Exporting alias 'refreshenv'.
Loading community extensions
Importing 'C:\ProgramData\chocolatey\extensions\chocolatey-core\chocolatey-core.psm1'
VERBOSE: Loading module from path 'C:\ProgramData\chocolatey\extensions\chocolatey-core\chocolatey-core.psm1'.
VERBOSE: Exporting function 'Get-UninstallRegistryKey'.
VERBOSE: Exporting function 'Get-AppInstallLocation'.
VERBOSE: Exporting function 'Get-AvailableDriveLetter'.
VERBOSE: Exporting function 'Get-EffectiveProxy'.
VERBOSE: Exporting function 'Get-PackageCacheLocation'.
VERBOSE: Exporting function 'Get-PackageParameters'.
VERBOSE: Exporting function 'Get-WebContent'.
VERBOSE: Exporting function 'Register-Application'.
VERBOSE: Exporting function 'Remove-Process'.
VERBOSE: Importing function 'Get-AppInstallLocation'.
VERBOSE: Importing function 'Get-AvailableDriveLetter'.
VERBOSE: Importing function 'Get-EffectiveProxy'.
VERBOSE: Importing function 'Get-PackageCacheLocation'.
VERBOSE: Importing function 'Get-PackageParameters'.
VERBOSE: Importing function 'Get-UninstallRegistryKey'.
VERBOSE: Importing function 'Get-WebContent'.
VERBOSE: Importing function 'Register-Application'.
VERBOSE: Importing function 'Remove-Process'.
VERBOSE: Exporting function 'Format-FileSize'.
VERBOSE: Exporting function 'Get-ChecksumValid'.
VERBOSE: Exporting function 'Get-ChocolateyUnzip'.
VERBOSE: Exporting function 'Get-ChocolateyWebFile'.
VERBOSE: Exporting function 'Get-EnvironmentVariable'.
VERBOSE: Exporting function 'Get-EnvironmentVariableNames'.
VERBOSE: Exporting function 'Get-FtpFile'.
VERBOSE: Exporting function 'Get-OSArchitectureWidth'.
VERBOSE: Exporting function 'Get-PackageParameters'.
VERBOSE: Exporting function 'Get-PackageParametersBuiltIn'.
VERBOSE: Exporting function 'Get-ToolsLocation'.
VERBOSE: Exporting function 'Get-UACEnabled'.
VERBOSE: Exporting function 'Get-UninstallRegistryKey'.
VERBOSE: Exporting function 'Get-VirusCheckValid'.
VERBOSE: Exporting function 'Get-WebFile'.
VERBOSE: Exporting function 'Get-WebFileName'.
VERBOSE: Exporting function 'Get-WebHeaders'.
VERBOSE: Exporting function 'Install-BinFile'.
VERBOSE: Exporting function 'Install-ChocolateyDesktopLink'.
VERBOSE: Exporting function 'Install-ChocolateyEnvironmentVariable'.
VERBOSE: Exporting function 'Install-ChocolateyExplorerMenuItem'.
VERBOSE: Exporting function 'Install-ChocolateyFileAssociation'.
VERBOSE: Exporting function 'Install-ChocolateyInstallPackage'.
VERBOSE: Exporting function 'Install-ChocolateyPackage'.
VERBOSE: Exporting function 'Install-ChocolateyPath'.
VERBOSE: Exporting function 'Install-ChocolateyPinnedTaskBarItem'.
VERBOSE: Exporting function 'Install-ChocolateyPowershellCommand'.
VERBOSE: Exporting function 'Install-ChocolateyShortcut'.
VERBOSE: Exporting function 'Install-ChocolateyVsixPackage'.
VERBOSE: Exporting function 'Install-ChocolateyZipPackage'.
VERBOSE: Exporting function 'Install-Vsix'.
VERBOSE: Exporting function 'Set-EnvironmentVariable'.
VERBOSE: Exporting function 'Set-PowerShellExitCode'.
VERBOSE: Exporting function 'Start-ChocolateyProcessAsAdmin'.
VERBOSE: Exporting function 'Test-ProcessAdminRights'.
VERBOSE: Exporting function 'Uninstall-BinFile'.
VERBOSE: Exporting function 'Uninstall-ChocolateyEnvironmentVariable'.
VERBOSE: Exporting function 'Uninstall-ChocolateyPackage'.
VERBOSE: Exporting function 'Uninstall-ChocolateyZipPackage'.
VERBOSE: Exporting function 'Update-SessionEnvironment'.
VERBOSE: Exporting function 'Write-ChocolateyFailure'.
VERBOSE: Exporting function 'Write-ChocolateySuccess'.
VERBOSE: Exporting function 'Write-FileUpdateLog'.
VERBOSE: Exporting function 'Write-FunctionCallLogMessage'.
VERBOSE: Exporting function 'Get-AppInstallLocation'.
VERBOSE: Exporting function 'Get-AvailableDriveLetter'.
VERBOSE: Exporting function 'Get-EffectiveProxy'.
VERBOSE: Exporting function 'Get-PackageCacheLocation'.
VERBOSE: Exporting function 'Get-WebContent'.
VERBOSE: Exporting function 'Register-Application'.
VERBOSE: Exporting function 'Remove-Process'.
VERBOSE: Exporting alias 'Get-ProcessorBits'.
VERBOSE: Exporting alias 'Get-OSBitness'.
VERBOSE: Exporting alias 'Get-InstallRegistryKey'.
VERBOSE: Exporting alias 'Generate-BinFile'.
VERBOSE: Exporting alias 'Add-BinFile'.
VERBOSE: Exporting alias 'Start-ChocolateyProcess'.
VERBOSE: Exporting alias 'Invoke-ChocolateyProcess'.
VERBOSE: Exporting alias 'Remove-BinFile'.
VERBOSE: Exporting alias 'refreshenv'.
VERBOSE: Importing function 'Format-FileSize'.
VERBOSE: Importing function 'Get-AppInstallLocation'.
VERBOSE: Importing function 'Get-AvailableDriveLetter'.
VERBOSE: Importing function 'Get-ChecksumValid'.
VERBOSE: Importing function 'Get-ChocolateyUnzip'.
VERBOSE: Importing function 'Get-ChocolateyWebFile'.
VERBOSE: Importing function 'Get-EffectiveProxy'.
VERBOSE: Importing function 'Get-EnvironmentVariable'.
VERBOSE: Importing function 'Get-EnvironmentVariableNames'.
VERBOSE: Importing function 'Get-FtpFile'.
VERBOSE: Importing function 'Get-OSArchitectureWidth'.
VERBOSE: Importing function 'Get-PackageCacheLocation'.
VERBOSE: Importing function 'Get-PackageParameters'.
VERBOSE: Importing function 'Get-PackageParametersBuiltIn'.
VERBOSE: Importing function 'Get-ToolsLocation'.
VERBOSE: Importing function 'Get-UACEnabled'.
VERBOSE: Importing function 'Get-UninstallRegistryKey'.
VERBOSE: Importing function 'Get-VirusCheckValid'.
VERBOSE: Importing function 'Get-WebContent'.
VERBOSE: Importing function 'Get-WebFile'.
VERBOSE: Importing function 'Get-WebFileName'.
VERBOSE: Importing function 'Get-WebHeaders'.
VERBOSE: Importing function 'Install-BinFile'.
VERBOSE: Importing function 'Install-ChocolateyDesktopLink'.
VERBOSE: Importing function 'Install-ChocolateyEnvironmentVariable'.
VERBOSE: Importing function 'Install-ChocolateyExplorerMenuItem'.
VERBOSE: Importing function 'Install-ChocolateyFileAssociation'.
VERBOSE: Importing function 'Install-ChocolateyInstallPackage'.
VERBOSE: Importing function 'Install-ChocolateyPackage'.
VERBOSE: Importing function 'Install-ChocolateyPath'.
VERBOSE: Importing function 'Install-ChocolateyPinnedTaskBarItem'.
VERBOSE: Importing function 'Install-ChocolateyPowershellCommand'.
VERBOSE: Importing function 'Install-ChocolateyShortcut'.
VERBOSE: Importing function 'Install-ChocolateyVsixPackage'.
VERBOSE: Importing function 'Install-ChocolateyZipPackage'.
VERBOSE: Importing function 'Install-Vsix'.
VERBOSE: Importing function 'Register-Application'.
VERBOSE: Importing function 'Remove-Process'.
VERBOSE: Importing function 'Set-EnvironmentVariable'.
VERBOSE: Importing function 'Set-PowerShellExitCode'.
VERBOSE: Importing function 'Start-ChocolateyProcessAsAdmin'.
VERBOSE: Importing function 'Test-ProcessAdminRights'.
VERBOSE: Importing function 'Uninstall-BinFile'.
VERBOSE: Importing function 'Uninstall-ChocolateyEnvironmentVariable'.
VERBOSE: Importing function 'Uninstall-ChocolateyPackage'.
VERBOSE: Importing function 'Uninstall-ChocolateyZipPackage'.
VERBOSE: Importing function 'Update-SessionEnvironment'.
VERBOSE: Importing function 'Write-ChocolateyFailure'.
VERBOSE: Importing function 'Write-ChocolateySuccess'.
VERBOSE: Importing function 'Write-FileUpdateLog'.
VERBOSE: Importing function 'Write-FunctionCallLogMessage'.
VERBOSE: Importing alias 'Add-BinFile'.
VERBOSE: Importing alias 'Generate-BinFile'.
VERBOSE: Importing alias 'Get-InstallRegistryKey'.
VERBOSE: Importing alias 'Get-OSBitness'.
VERBOSE: Importing alias 'Get-ProcessorBits'.
VERBOSE: Importing alias 'Invoke-ChocolateyProcess'.
VERBOSE: Importing alias 'refreshenv'.
VERBOSE: Importing alias 'Remove-BinFile'.
VERBOSE: Importing alias 'Start-ChocolateyProcess'.
---------------------------Script Execution---------------------------
Running 'ChocolateyScriptRunner' for 7zip.install v19.0 with packageScript 'C:\ProgramData\chocolatey\lib\7zip.install\t
ools\chocolateyInstall.ps1', packageFolder:'C:\ProgramData\chocolatey\lib\7zip.install', installArguments: '', packagePa
rameters: '',
Running 'C:\ProgramData\chocolatey\lib\7zip.install\tools\chocolateyInstall.ps1'
Running Get-OSArchitectureWidth -compare '64'
Installing 64 bit version
Running Install-ChocolateyInstallPackage -silentArgs '/S' -file 'C:\ProgramData\chocolatey\lib\7zip.install\tools\7zip_x
64.exe' -fileType 'exe' -validExitCodes '0' -packageName '7zip.install'
Running Get-ProcessorBits -compare '32'
Installing 7zip.install...
Running Start-ChocolateyProcessAsAdmin -validExitCodes '0' -workingDirectory 'C:\ProgramData\chocolatey\lib\7zip.install
\tools' -statements '/S ' -exeToRun 'C:\ProgramData\chocolatey\lib\7zip.install\tools\7zip_x64.exe'
Unable to use current location for Working Directory. Using Cache Location instead.
Test-ProcessAdminRights: returning True
Elevating permissions and running ["C:\ProgramData\chocolatey\lib\7zip.install\tools\7zip_x64.exe" /S ]. This may take a
 while, depending on the statements.
Command ["C:\ProgramData\chocolatey\lib\7zip.install\tools\7zip_x64.exe" /S ] exited with '-1073741511'.
ERROR: Running ["C:\ProgramData\chocolatey\lib\7zip.install\tools\7zip_x64.exe" /S ] was not successful. Exit code was '
-1073741511'. See log for possible error messages.
 at Start-ChocolateyProcessAsAdmin, C:\ProgramData\chocolatey\helpers\functions\Start-ChocolateyProcessAsAdmin.ps1: line
 324
at Install-ChocolateyInstallPackage, C:\ProgramData\chocolatey\helpers\functions\Install-ChocolateyInstallPackage.ps1: l
ine 335
at <ScriptBlock>, C:\ProgramData\chocolatey\lib\7zip.install\tools\chocolateyInstall.ps1: line 16
at <ScriptBlock>, C:\ProgramData\chocolatey\helpers\chocolateyScriptRunner.ps1: line 49
at <ScriptBlock>, <No file>: line 1
Built-in PowerShell host called with ['[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.Th
read]::CurrentThread.CurrentUICulture = ''; & import-module -name 'C:\ProgramData\chocolatey\helpers\chocolateyInstaller
.psm1'; & 'C:\ProgramData\chocolatey\helpers\chocolateyScriptRunner.ps1' -packageScript 'C:\ProgramData\chocolatey\lib\7
zip.install\tools\chocolateyInstall.ps1' -installArguments '' -packageParameters '''] exited with '-1073741511'.
Calling command ['"C:\Windows\System32\shutdown.exe" /a']
Command ['"C:\Windows\System32\shutdown.exe" /a'] exited with '1116'
Capturing package files in 'C:\ProgramData\chocolatey\lib\7zip.install'
 Found 'C:\ProgramData\chocolatey\lib\7zip.install\7zip.install.nupkg'
  with checksum 'C9C2399FBD769A6964ADE0C9D3509898'
 Found 'C:\ProgramData\chocolatey\lib\7zip.install\7zip.install.nuspec'
  with checksum '6B20F0946351971DF2D0D2E9BD021438'
 Found 'C:\ProgramData\chocolatey\lib\7zip.install\legal\LICENSE.txt'
  with checksum '650BD91878930A925935C6103A4422CC'
 Found 'C:\ProgramData\chocolatey\lib\7zip.install\legal\VERIFICATION.txt'
  with checksum 'ADCFFBF81623DAB3DBD2C6F6D6216D31'
 Found 'C:\ProgramData\chocolatey\lib\7zip.install\tools\7zip_x32.exe'
  with checksum 'FABE184F6721E640474E1497C69FFC98'
 Found 'C:\ProgramData\chocolatey\lib\7zip.install\tools\7zip_x64.exe'
  with checksum 'D7B20F933BE6CDAE41EFBE75548EBA5F'
 Found 'C:\ProgramData\chocolatey\lib\7zip.install\tools\7zip_x64.exe.ignore'
  with checksum 'BEA07E6D2B8DCE396FE21BAA61B34956'
 Found 'C:\ProgramData\chocolatey\lib\7zip.install\tools\chocolateyInstall.ps1'
  with checksum '0BCA1D66A247FCE19914D0F2C63E6581'
 Found 'C:\ProgramData\chocolatey\lib\7zip.install\tools\chocolateyUninstall.ps1'
  with checksum '9575DFA835A44C14B24732DC994B5C96'
Attempting to create directory "C:\ProgramData\chocolatey\.chocolatey\7zip.install.19.0".
There was no original file at 'C:\ProgramData\chocolatey\.chocolatey\7zip.install.19.0\.files'
Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\7zip.install.19.0\.arguments".
Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\7zip.install.19.0\.extra".
Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\7zip.install.19.0\.version".
Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\7zip.install.19.0\.sxs".
Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\7zip.install.19.0\.pin".
Sending message 'HandlePackageResultCompletedMessage' out if there are subscribers...
The install of 7zip.install was NOT successful.
Error while running 'C:\ProgramData\chocolatey\lib\7zip.install\tools\chocolateyInstall.ps1'.
 See log for details.
Attempting to create directory "C:\ProgramData\chocolatey\lib-bad".
Moving 'C:\ProgramData\chocolatey\lib\7zip.install'
 to 'C:\ProgramData\chocolatey\lib-bad\7zip.install'
Attempting to delete file "C:\Users\ContainerAdministrator\AppData\Local\NuGet\Cache\7zip.install.19.0.nupkg".

Chocolatey installed 1/2 packages. 1 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Failures
 - 7zip.install (exited -1073741511) - Error while running 'C:\ProgramData\chocolatey\lib\7zip.install\tools\chocolateyI
nstall.ps1'.
 See log for details.
Sending message 'PostRunMessage' out if there are subscribers...
Exiting with -1073741511
chocolatey/choco

Answer questions StefanScherer

Hi William, Sure, I took the Dockerfile from the first comment and added the comment to enable PowerShell line continuation sign, this also enables easier backslash support.

# escape=`
ARG WIN_VER="ltsc2019"
FROM mcr.microsoft.com/windows/servercore:$WIN_VER
WORKDIR C:\temp
ADD https://chocolatey.org/install.ps1 C:\TEMP\choco-install.ps1
SHELL ["cmd", "/S", "/C"]
RUN powershell C:\TEMP\choco-install.ps1
RUN choco install 7zip.install -y
RUN choco install msys2 --params "/NoUpdate /InstallDir:C:\msys2" -y

I created a fresh Windows Server 2019 in Azure, installed Docker as described here, then created a test folder with the Dockerfile and opened a PowerShell terminal and ran

docker build -t msys2 .

This worked fine for me. I also pushed the image to stefanscherer/msys2.

useful!
source:https://uonfu.com/
answerer
Stefan Scherer StefanScherer @docker Erlangen, Germany https://stefanscherer.github.io Engineering manager @docker, Microsoft MVP, Retired Docker Captain
Github User Rank List