Very slow RUN on docker on windows containers - windows

I installed docker on a Windows 10 machine via chocolatey
choco install docker-desktop
Then I have built this image
FROM mcr.microsoft.com/windows/servercore:ltsc2016
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
RUN Invoke-WebRequest -UseBasicParsing https://chocolatey.org/install.ps1 | Invoke-Expression
And it runs reasonably fast
Then I try to run this one
FROM chocolatey
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
RUN cinst -y netfx-4.7.2-devpack
After downloading the .net installer the process fails with timeout.
The last thing in the log is Installing dotnetfx...
No idea why and how to debug.
Anyone has the same issue? Where do I start debugging this issue?

I dont have a definitive answer for this but my current workaround is to use the sdk base image from microsoft from https://hub.docker.com/_/microsoft-dotnet-framework-sdk/

Related

Correct way to install VirtualBox from electron app on windows

I'm trying to install VirtualBox from an electron app to the host machine.
Currently I do the following:
(virtualbox installer is packaged in the electron app)
await util.sudoExec(`
copy ${app.getAppPath()}\\..\\resources\\installers\\VirtualBox-6.1.8-137981-Win.exe ${temp}\\pkg.exe &
${temp}\\pkg.exe /extract --silent &
msiexec /i ${temp}\\VirtualBox\\VirtualBox-6.1.8-r137981.msi /quiet /norestart ALLUSERS=2 VBOX_INSTALLDESKTOPSHORTCUT=0 VBOX_INSTALLQUICKLAUCHSHORTCUT=0
`)
The above code is working 70%. In some cases I got an error message ie.:
'C:\Users\Username\AppData\Local\Temp\pkg.exe' is not recognized as an internal or external command,
operable program or batch file.
I'm not sure this is the best way to install VB.
You could try to use Chocolatey:
This will install it:
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'))
And this command will install Virtualbox:
choco install virtualbox -y
This would also allow you to easily update the software whenever you need to. It's an option so you don't need to maintain package installers for each version of VB.
There is an answer , I think it could help you
'' is not recognized as an internal or external command, operable program or batch file
see the answer of Gerhard on this question

Unable to install or run Octave in a Windows docker container

I'm trying to create a Windows docker container image with Octave (CLI) installed.
I started off with a Dockerfile installing Octave via chocolatey:
FROM mcr.microsoft.com/windows/servercore:1809
# Install chocolatey
RUN ["powershell", "Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"]
# Install Octave
RUN ["powershell", "choco install --yes octave"]
Unfortunately the Octave install times out after 2700 seconds, while on my local machine this takes less than 10 minutes.
Progress: 100% - Completed download of C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\octave.install\5.1.0\octave-5.1.0-w64-installer.exe (286.41 MB).
Download of octave-5.1.0-w64-installer.exe (286.41 MB) completed.
Hashes match.
Installing octave.install...
Chocolatey timed out waiting for the command to finish. The timeout
specified (or the default value) was '2700' seconds. Perhaps try a
higher `--execution-timeout`? See `choco -h` for details.
The install of octave.install was NOT successful.
Error while running 'C:\ProgramData\chocolatey\lib\octave.install\tools\chocolateyinstall.ps1'.
See log for details.
In my second trial I ran a Windows servercore container, copied the Octave installer binary into there and tried to run it, however the start call unfortunately immediately returns with error code -1073741515.
My third trial was downloading the portable Octave version and copy it into a running Windows servercore container, copy the portable Octave and run it. Unfortunately when calling octave-cli.exe the call again returns immediately with error code -1073741515.
I then checked with dependency walker, on my local machine, which dependencies the octave-cli has, it seemed to depend on adoptopenjdk\jdk-14.0.1.7. In my last trial I installed this dependency in the Windows servercore container via choco install adoptopenjdk, this however resulted in the same error code.
I'm curious whether anybody did succeed in installing or running Octave into a Windows docker container?
Or does anyone have any hints for me to proceed?

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:\Users\ADMINI~1\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip to C:\Users\ADMINI~1\AppData\Local\Temp\chocolatey\chocInstall...
Installing chocolatey on this machine
Creating ChocolateyInstall as an environment variable (targeting 'Machine')
Setting ChocolateyInstall to 'C:\ProgramData\chocolatey'
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:\ProgramData\chocolatey\lib'
(i.e. C:\ProgramData\chocolatey\lib\yourPackageName).
A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin'
and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'.
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:\ProgramData\chocolatey\bin in it. Adding...
WARNING: Not setting tab completion: Profile file does not exist at
'C:\Users\Administrator\Documents\WindowsPowerShell\Microsoft.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:\Users\Administrator\example> 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:\Users\Administrator\example> 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:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip to C:\Users\ContainerAdministrator\AppData\Local\Temp\chocolatey\chocInstall...
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:\Users\Administrator\example>
There have been a few issues from TLS changes to changes to the microsoft base images that have caused me some problems with 7zip and choco over the last 3 weeks. I've got my base images working now by adding the following:
RUN $text = '[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls13 -bor [Net.SecurityProtocolType]::Tls12 -bor [Net.SecurityProtocolType]::Ssl3 -bor [Net.SecurityProtocolType]::Tls'; \
$text | Set-Content 'C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1';
RUN powershell -Command Set-ExecutionPolicy Bypass -Scope Process -Force; \
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')); \
powershell -Command refreshenv; \
cinst -y --allow-empty-checksums 7zip.install make nuget.commandline --no-progress;
However I am still experiencing some issue in other images with the reported error: "7-Zip signalled an unknown error (code -1073741511)", however no doubt they boil down to the same thing. Again, if I exec in to the running container, I am able to manually run choco and install 7zip and even access the "7z" commands. I tried committing the container once I made the changes, but still got this issue.

How to install Tomcat in Docker Windows Server Container?

On my windows server 2016 tp5 virtual machine, I would like to create a simple native windows based docker example without virtualbox.
The example needs tomcat for windows and since this windows server 2016 docker container uses a shared windows kernel, installing tomcat should be straight forward, alas! Using the following powershell docker build command stops with non-zero code: 255
Dockerfile in c:\build:
FROM microsoft/windowsservercore
RUN powershell -Command wget -Uri mirror.klaus-uwe.me/apache/tomcat/tomcat-7/v7.0.70/bin/apache-tomcat-7.0.70-windows-x64.zip -OutFile "$env:TEMP\tomcat-7.0.70.zip"
Admin-powershell:
docker build c:\build
Result:
---> Running in 317a3572890e
The command 'cmd /S /C powershell -Command wget -Uri mirror.klaus-uwe.me/apache/tomcat/tomcat-7/v7.0.70/bin/apache-tomca
t-7.0.70-windows-x64.zip -OutFile "$env:TEMP\tomcat-7.0.70.zip"' returned a non-zero code: 255
Although the zip file has been downloaded in my users temp dir.
Can anybody tell me, how a native windows tomcat installation should look like, as I am not really deep in this stuff.
As mentioned here:
The error code "255" usually means that it is not able to find the file you are asking it to execute
So try and test with the full path and name of the binary(ies) involved in your RUN command line (like powershell)
But test also a simpler case:
RUN dir c:\Users\
This has been recently reported as failing with the same exit code 255, which would mean the latest docker on Windows Server 2016 Technical Preview 5 has a bug.

Docker on Windows Server 2016 TP4 Downloading git in container through powershell

I have an angular UI and a nodejs api. I am currently running windows server 2016 TP4 in Azure.Here are the steps I go through:
I am able to remote in, create images, create containers based off those images, and attach to those containers no problem.
I pulled a nodejs image from docker: docker pull microsoft/node and then created a container from that image: docker run --name 'my_api_name' -it microsoft/node cmd
That command takes me into the container via a windows command prompt. I type powershell which takes me into a powershell shell and i can run npm commands.
My question is, how do I install git onto this container? I want to reach out to the repository holding my app, pull it down and run it in this container. I will eventually push this container image up to the docker registry so clients can pull it down and run it on their windows env.
You can do it like this in admin shell:
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
cinst -y git
Ideally you wouldn't add git to the container and try to pull your repo into it (that will also get messy with credentials for private repos
You should do your source control management on your host and then build the source code into a container. It's not yet there for the Windows Dockerfiles, but the Linux ones have ONBUILD. It should be possible to replicate that for Windows.
RUN #powershell iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
RUN cinst -y git
Refer: Unable to install git and python packages inside Windows container
Solved this by downloading the "Portable" version of Git. Copying those files into the container and ***then running the post installation script provided by Git.
Find appropriate download here: https://git-scm.com/download/win
Inside docker file:
ADD Git64/ C:/Git/
WORKDIR C:/Git/
RUN %windir%\System32\cmd.exe "/K" C:\Git\post-install.bat

Resources