Dockerfile ENTRYPOINT EXEC form not working with Powershell

Moerwald

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

Dan

Try removing the trailing space at the end of "Get-ChildItem "

Failing that, is it interpreting \' after Program Files as an escaped character ?

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to exec into Docker container with ENTRYPOINT in its Dockerfile

Dockerfile CMD shell versus exec form

What is the difference between CMD and ENTRYPOINT in a Dockerfile?

confused with CMD and ENTRYPOINT in dockerfile

How to specify working directory for ENTRYPOINT in Dockerfile

Dockerfile: ENTRYPOINT and CMD

What is exec in Dockerfile ENTRYPOINT and why is a process started twice without it?

Dockerfile Entrypoint issue

Dockerfile with entrypoint only from base image

Dockerfile execute additional scripts in entrypoint

Docker: Best practices for installing dependencies - Dockerfile or ENTRYPOINT?

Understanding Dockerfile CMD/ENTRYPOINT

exec not found using Dockerfile ENTRYPOINT

Form input not working in Workflow (PowerShell)

Set project directory as Workdir for Entrypoint in Dockerfile

Dockerfile ENTRYPOINT with parameters

Access dockerfile ENV variables in entrypoint

Entrypoint's exec form executed through shell

Docker RUN command in exec form not working

Dockerfile not working - running command manually works, but same command through run or entrypoint doesn't work

Override ENTRYPOINT configuration in Micronaut Gradle Dockerfile

Dockerfile without CMD or Entrypoint

Dockerfile entrypoint/cmd not executing on container import

Entrypoint clause not working in the dockerfile

Exec form of RUN instruction in Dockerfile

Dockerfile - exec form of ENTRYPOINT and shell form of CMD

dockerfile : npm not found at entrypoint?

Entrypoint file not being found for Dockerfile

Dockerfile ENTRYPOINT ignores WORKDIR