3

I have a Windows Server 2016 AWS Workspace. I was able to install Docker. I want to create an image that has Java 8 and the Scoop package manager. I get Java installed fine and the Scoop install runs during docker build but when I run the container, only Java is installed. scoop is an unknown command and I have to reinstall it. It's possibly installed under another user but I can't seem to find any trace of it. I would also love to scoop install git curl etc... a couple of utilities. I would like to run the image and the tools are all ready to go. Can anyone point me in the right direction? My Dockerfile looks like this so far

FROM mcr.microsoft.com/windows/servercore:ltsc2016

# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

ENV JAVA_HOME C:\\openjdk-8
RUN $newPath = ('{0}\bin;{1}' -f $env:JAVA_HOME, $env:PATH); \
    Write-Host ('Updating PATH: {0}' -f $newPath); \
# Nano Server does not have "[Environment]::SetEnvironmentVariable()"
    setx /M PATH $newPath

# https://adoptopenjdk.net/upstream.html
ENV JAVA_VERSION 8u222
ENV JAVA_BASE_URL https://github.com/AdoptOpenJDK/openjdk8-upstream-binaries/releases/download/jdk8u222-b10/OpenJDK8U-jdk_
ENV JAVA_URL_VERSION 8u222b10
# https://github.com/docker-library/openjdk/issues/320#issuecomment-494050246

RUN $url = ('{0}x64_windows_{1}.zip' -f $env:JAVA_BASE_URL, $env:JAVA_URL_VERSION); \
    Write-Host ('Downloading {0} ...' -f $url); \
    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
    Invoke-WebRequest -Uri $url -OutFile 'openjdk.zip'; \
# TODO signature? checksum?
    \
    Write-Host 'Expanding ...'; \
    New-Item -ItemType Directory -Path C:\temp | Out-Null; \
    Expand-Archive openjdk.zip -DestinationPath C:\temp; \
    Move-Item -Path C:\temp\* -Destination $env:JAVA_HOME; \
    Remove-Item C:\temp; \
    \
    Write-Host 'Removing ...'; \
    Remove-Item openjdk.zip -Force; \
    \
    Write-Host 'Verifying install ...'; \
    Write-Host '  javac -version'; javac -version; \
    Write-Host '  java -version'; java -version; \
    \
    Write-Host 'Complete.'

I tried adding

iex (new-object net.webclient).downloadstring('https://get.scoop.sh')

But then the image won't build so I removed that line.

How can I install scoop (or maybe chocolatey) in this image and include a couple utilities so that when the container is run, those utils are ready to use?

Hcabnettek
  • 12,678
  • 38
  • 124
  • 190

0 Answers0