gpt4 book ai didi

powershell - Dockerfile ENTRYPOINT EXEC表单不适用于Powershell

转载 作者:行者123 更新时间:2023-12-02 19:31:44 29 4
gpt4 key购买 nike

我必须遵循(简单的)Dockerfile:

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

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

At line:1 char:77 + ... ference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; ["Get-Chi ... + ~ Missing type name after '['. At line:1 char:93 + ... $ProgressPreference = 'SilentlyContinue'; ["Get-ChildItem ", "-Path" ... + ~ Missing argument in parameter list. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordEx ception + FullyQualifiedErrorId : MissingTypename



我也尝试过:
 ENTRYPOINT ["Get-ChildItem ", "-Path 'C:\Program Files\'"]

并得到相同的错误。

如果我使用Dockerfile中的ENTRYPOINT形式的 shell 程序:
FROM microsoft/windowsservercore:latest
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ENTRYPOINT Get-ChildItem -Path 'C:\Program Files\'

一切正常。

有人可以告诉我在使用ENTRYPOINT时如何在“exec-form”中编写此简单的PS命令。我问,因为 the docker reference指出“exec-form”是首选格式。

谢谢

最佳答案

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

失败的是,它将程序文件后的\'解释为转义字符吗?

关于powershell - Dockerfile ENTRYPOINT EXEC表单不适用于Powershell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50567800/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com