powershell - Dockerfile ENTRYPOINT EXEC form not working with Powershell
问题描述
I have to following (simple) Dockerfile:
FROM microsoft/windowsservercore:latest
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ENTRYPOINT ["Get-ChildItem ", "-Path", "'C:\Program Files\'"]
If I run the container. I get the following error:
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
I also tried:
ENTRYPOINT ["Get-ChildItem ", "-Path 'C:\Program Files\'"]
and got the same error.
If I use the shell form the ENTRYPOINT in the Dockerfile:
FROM microsoft/windowsservercore:latest
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ENTRYPOINT Get-ChildItem -Path 'C:\Program Files\'
Everything works fine.
Can somebody tell me how to write this simple PS command in the "exec-form" when using ENTRYPOINT. I'm asking since the docker reference states that the "exec-form" is the preferred one.
Thx
解决方案
Try removing the trailing space at the end of "Get-ChildItem "
Failing that, is it interpreting \' after Program Files as an escaped character ?
推荐阅读
- vb.net - 使用 Httpwebrequest vb.net 登录网站
- python - 我需要什么降价模板,以便在使用 nbconvert 导出时,Jupyter 笔记本中的输出单元格与输入单元格看起来不同
- postgresql - 如何在时间戳后附加间隔偏移量
- flutter - 显示键盘时如何隐藏cupertinoTabBar?或者如何让键盘覆盖酒吧?还是将标签栏始终保持在底部?
- javascript - 为什么即使填充设置为'rgba(0,0,0,0)',最近绘制的弧也有黑色填充?
- python - 用与其他列相同的行数填充列的更好方法
- vue.js - Vue.js push.route 不改变 App 中的组件
- tomcat - 一些管理 Jenkins 链接不起作用 - Nginx 反向代理,Tomcat
- c# - 对 Inspector.CurrentItem 的引用会导致提醒不断回来
- r - 我可以优化“插入符号”中的中值相对绝对误差吗?