【发布时间】:2022-08-05 15:48:25
【问题描述】:
我正在 Docker Desktop (Windows) 中构建基于 Nanoserver 的 docker 映像。
我的 Dockerfile 看起来像这样:
# Nano Server - IIS
FROM mcr.microsoft.com/powershell:lts-nanoserver-20h2-20220318
SHELL [\"pwsh\", \"-Command\", \"$ErrorActionPreference = \'Stop\'; $ProgressPreference = \'SilentlyContinue\';\"]
USER ContainerAdministrator
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \\
Install-PackageProvider -Name NanoServerPackage -Force -Scope AllUsers ; \\
Get-Package -Name Microsoft-NanoServer-IIS-Package -ProviderName NanoServerPackage -Scope AllUsers -Force -Verbose \\
| Install-Package -Name Microsoft-NanoServer-IIS-Package -ProviderName NanoServerPackage -Scope AllUsers -Force -Verbose ; \\
Write-Output \"done\"
USER ContainerUser
当我运行docker build 时,RUN 命令失败并出现错误:\"Get-Package: A parameter cannot be found that match parameter name \'Scope\'.\"
根据Powershell docs,Get-Package 确实采用了-Scope 参数。我在这里想念什么?
$PSVersionTable 输出:
Name Value
---- -----
PSVersion 7.2.2
PSEdition Core
GitCommitId 7.2.2
OS Microsoft Windows 10.0.19042
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
标签: dockerfile docker-build powershell-core