Chocolatey installs locally but not in a docker build (but it did last week) – Why?

I am trying to use chocolatey to install packages into a windows container. I actually just wanted to change one of the packages, rebuild and push and now, suddenly, it doesn’t work. When I test it on the host (run the same command as the container) it works just fine. It has some kind of an issue with that container installation since last build. I can only suspect the base image changed. But, maybe not

On the host:

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
                           Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Getting latest version of the Chocolatey package for download.
Getting Chocolatey from https://chocolatey.org/api/v2/package/chocolatey/0.10.15.
Downloading 7-Zip commandline tool prior to extraction.
Extracting C:UsersADMINI~1AppDataLocalTempchocolateychocInstallchocolatey.zip to C:UsersADMINI~1AppDataLocalTempchocolateychocInstall...
Installing chocolatey on this machine
Creating ChocolateyInstall as an environment variable (targeting 'Machine')
  Setting ChocolateyInstall to 'C:ProgramDatachocolatey'
WARNING: It's very likely you will need to close and reopen your shell
  before you can use choco.
Restricting write permissions to Administrators
We are setting up the Chocolatey package repository.
The packages themselves go to 'C:ProgramDatachocolateylib'
  (i.e. C:ProgramDatachocolateylibyourPackageName).
A shim file for the command line goes to 'C:ProgramDatachocolateybin'
  and points to an executable in 'C:ProgramDatachocolateylibyourPackageName'.

Creating Chocolatey folders if they do not already exist.

WARNING: You can safely ignore errors related to missing log files when
  upgrading from a version of Chocolatey less than 0.9.9.
  'Batch file could not be found' is also safe to ignore.
  'The system cannot find the file specified' - also safe.
chocolatey.nupkg file not installed in lib.
 Attempting to locate it from bootstrapper.
PATH environment variable does not have C:ProgramDatachocolateybin in it. Adding...
WARNING: Not setting tab completion: Profile file does not exist at
'C:UsersAdministratorDocumentsWindowsPowerShellMicrosoft.PowerShell_profile.ps1'.
Chocolatey (choco.exe) is now ready.
You can call choco from anywhere, command line or powershell by typing choco.
Run choco /? for a list of functions.
You may need to shut down and restart powershell and/or consoles
 first prior to using choco.
Ensuring chocolatey commands are on the path
Ensuring chocolatey.nupkg is in the lib folder

same host, but this time, in a Dockerfile

PS C:UsersAdministratorexample> cat Dockerfile
# escape=`
ARG SDK_VERSION=4.8

# Use the latest Windows Server Core image with .NET Framework 4.8.
FROM mcr.microsoft.com/dotnet/framework/sdk:${SDK_VERSION}

# Disable Healthcheck
HEALTHCHECK NONE
RUN Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
RUN choco install adoptopenjdk8openj9jre -y
RUN choco install nuget.commandline -y
RUN choco install yarn -y
RUN choco install gitversion.portable -y
RUN choco install sonarscanner-msbuild-net46 -y

CMD ["powershell.exe", "-NoLogo", "-ExecutionPolicy", "Bypass"]

PS C:UsersAdministratorexample> docker build -t example .
Sending build context to Docker daemon  4.096kB
Step 1/10 : ARG SDK_VERSION=4.8
Step 2/10 : FROM mcr.microsoft.com/dotnet/framework/sdk:${SDK_VERSION}
4.8: Pulling from dotnet/framework/sdk
65014b3c3121: Already exists
b5405b758079: Pull complete
ac56c610af03: Pull complete
d8d61c2ababf: Pull complete
0ed57babb001: Pull complete
c8a0f45b3421: Pull complete
75cb34f91825: Pull complete
1949a0bb0ffb: Pull complete
316fdf3fc0fa: Pull complete
42b0925a3e5c: Pull complete
c5e384761600: Pull complete
f65f633b9854: Pull complete
bd885be04626: Pull complete
179844769b6b: Pull complete
c037183d4738: Pull complete
Digest: sha256:0008d5d893924c10ec01b1619a009c57116f9a943fe43ca772af544c75c9a83a
Status: Downloaded newer image for mcr.microsoft.com/dotnet/framework/sdk:4.8
 ---> 99ad7e1e8763
Step 3/10 : HEALTHCHECK NONE
 ---> Running in f679ce4e5789
Removing intermediate container f679ce4e5789
 ---> a08984a9afe8
Step 4/10 : RUN Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
 ---> Running in 656ed514a137
Getting latest version of the Chocolatey package for download.
Getting Chocolatey from https://chocolatey.org/api/v2/package/chocolatey/0.10.15.
Downloading 7-Zip commandline tool prior to extraction.
Extracting C:UsersContainerAdministratorAppDataLocalTempchocolateychocInstallchocolatey.zip to C:UsersContainerAdministratorAppDataLocalTempchocolateychocInstall...
Unable to unzip package using 7zip. Perhaps try setting
$env:chocolateyUseWindowsCompression = 'true' and call install again. Error:
7-Zip signalled an unknown error (code -1073741511)
At line:220 char:15
+ ...   default { throw "$errorMessage 7-Zip signalled an unknown error (co ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Unable to unzip...de -1073741
   511):String) [], RuntimeException
    + FullyQualifiedErrorId : Unable to unzip package using 7zip. Perhaps try
   setting $env:chocolateyUseWindowsCompression = 'true' and call install aga
  in. Error: 7-Zip signalled an unknown error (code -1073741511)

The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))' returned a non-zero code: 1
PS C:UsersAdministratorexample>

Source: StackOverflow