我如何在mcr.microsoft.com/powershell容器上运行`powershell`命令

问题描述 投票:0回答:1

我的Docker映像来自已安装mcr.microsoft.com/powershell:latestpowershell。为什么在构建docker映像时出现此错误:/bin/sh: 1: Install-Module: not found

下面是我的dockerfile:

FROM mcr.microsoft.com/powershell:latest
RUN Install-Module dbatools -Force

当我从Install-Module dbatools -Force手动启动容器时,可以运行命令mcr.microsoft.com/powershell:latest。为什么不能通过构建映像来运行它?是否有不同的背景?如果它使用本地主机上下文,是否意味着我需要在Mac OS上安装powershell

如果我想以ENTRYPOINT的身份运行Powershell脚本,如何指定它?

docker
1个回答
0
投票

您可以在SHELL中使用Dockerfile指令:

SHELL ["powershell","-command"]
RUN New-Item -ItemType Directory C:\Example

查看更多here

© www.soinside.com 2019 - 2024. All rights reserved.