Dockerfile ENTRYPOINT EXEC表单不与Powershell一起使用

时间:2018-05-28 13:41:25

标签: powershell docker

我必须关注(简单)Dockerfile:

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

如果我运行容器。我收到以下错误:

  

在行:1字符:77 + ... ference ='停止&#39 ;; $ ProgressPreference =' SilentlyContinue&#39 ;; [" Get-Chi ......   +〜   ' ['。之后缺少类型名称。   在行:1字符:93   + ... $ ProgressPreference =' SilentlyContinue&#39 ;; [" Get-ChildItem"," -Path" ...   +〜   缺少参数列表中的参数。       + CategoryInfo:ParserError:(:) [],ParentContainsErrorRecordEx      ception       + FullyQualifiedErrorId:MissingTypename

我也尝试过:

 ENTRYPOINT ["Get-ChildItem ", "-Path 'C:\Program Files\'"]

并得到了同样的错误。

如果我使用shell形成Dockerfile中的ENTRYPOINT:

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

一切正常。

有人可以告诉我如何在" exec-form"中编写这个简单的PS命令。使用ENTRYPOINT时。自the docker reference以来,我问过" exec-form"是首选。

THX

1 个答案:

答案 0 :(得分:0)

尝试删除" Get-ChildItem"

结束时的尾随空格

如果做不到的话,是否正在解释\'将Program Files作为转义字符后?

相关问题