Dockerfile入口点执行窗体不使用Powershell

Dockerfile入口点执行窗体不使用Powershell,powershell,docker,Powershell,Docker,我必须创建以下(简单)Dockerfile: FROM microsoft/windowsservercore:latest SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] ENTRYPOINT ["Get-ChildItem ", "-Path", "'C:\Program Files\'"] FROM microsof

我必须创建以下(简单)Dockerfile:

FROM microsoft/windowsservercore:latest
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ENTRYPOINT ["Get-ChildItem ", "-Path", "'C:\Program Files\'"]
FROM microsoft/windowsservercore:latest
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ENTRYPOINT Get-ChildItem -Path 'C:\Program Files\'
如果我运行容器。我得到以下错误:

第1行字符:77+。。。引用='停止'$ProgressPreference='SilentlyContinue';[“得到Chi。。。 + ~ “[”之后缺少类型名称。 第1行字符:93 +…$ProgressPreference='SilentlyContinue';[“Get ChildItem”,“-Path”。。。 + ~ 参数列表中缺少参数。 +CategoryInfo:ParserError:(:)[],ParentContainerRorRecordEx 概念 +FullyQualifiedErrorId:MissingTypename

我还尝试:

 ENTRYPOINT ["Get-ChildItem ", "-Path 'C:\Program Files\'"]
得到了同样的错误

如果我在Dockerfile中使用shell表单入口点:

FROM microsoft/windowsservercore:latest
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ENTRYPOINT ["Get-ChildItem ", "-Path", "'C:\Program Files\'"]
FROM microsoft/windowsservercore:latest
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ENTRYPOINT Get-ChildItem -Path 'C:\Program Files\'
一切正常

有人能告诉我在使用ENTRYPOINT时如何在“exec form”中编写这个简单的PS命令吗?我想问的是,因为“exec form”是首选的


Thx

尝试删除“Get ChildItem”结尾的尾随空格


如果失败,是否将“after”程序文件解释为转义字符?

简单地通读一遍,我认为这是因为Shell表单使用Shell(或cmd/c默认值)中定义的内容和Exec表单,您需要在命令中显式调用可执行文件
powershell.exe
-命令“,”$ErrorActionPreference='Stop';$ProgressPreference='SilentlyContinue';Get ChildItem-Path'C:\Program Files\'”]work?这是参考资料中让我得出结论的部分:SHELL指令允许覆盖用于命令SHELL形式的默认SHELL。不幸的是,我得到了相同的错误。如果您对这个问题更感兴趣,我已将docker映像和Dockerfile上载到:我没有机会查看它这是一个实际的容器,但我认为另一件事是,在使用Exec表单时,像\这样的一些字符需要转义。例如,
C:\Program Files
->
C:\\Program Files