1

我有一个 Windows Server 2016 AWS 工作区。我能够安装 Docker。我想创建一个具有 Java 8 和 Scoop 包管理器的图像。我很好地安装了 Java,并且 Scoop 安装在 docker build 期间运行,但是当我运行容器时,只安装了 Java。scoop 是一个未知命令,我必须重新安装它。它可能安装在另一个用户下,但我似乎找不到任何痕迹。我也很想scoop install git curl等...几个实用程序。我想运行映像,工具都准备好了。谁能指出我正确的方向?到目前为止,我的 Dockerfile 看起来像这样

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.'

我尝试添加

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

但是随后图像将无法构建,因此我删除了该行。

如何在此映像中安装 scoop(或者可能是巧克力)并包含几个实用程序,以便在容器运行时,这些实用程序可以使用?

4

0 回答 0