2

I need to execute PowerShell-script and after launch nginx.exe in my Windows-container, so I've added an entrypoint to my Dockerfile as below:

ENTRYPOINT ["powershell", "C:\nginx\Configure-Nginx.ps1 && C:\nginx\nginx.exe"]

But it doesn't work.

I am noobie with PowerShell... How to make it correctly?

3
  • 1
    In principle (may not solve all of your problems): powershell.exe is the CLI of Windows PowerShell, where the pipeline-chaining && operator isn't supported (it requires PowerShell (Core) v7+; PowerShell (Core)'s CLI is pwsh.exe). To emulate &&, use C:\nginx\Configure-Nginx.ps1; if ($?) { C:\nginx\nginx.exe } Commented May 25, 2021 at 12:36
  • 1
    Also, I think you must escape the backslashes in your array elements -> ENTRYPOINT ["powershell", "C:\\nginx\\Configure-Nginx.ps1; if ($?) { C:\\nginx\\nginx.exe }"] Commented May 25, 2021 at 12:46
  • Thank you for comments, I've check my PowerShell version, you're right, I use 5.1, it doesn't support && operator Commented May 25, 2021 at 12:54

1 Answer 1

2

From what I see here you want to do two things:

  1. Run powershell script before container starts
  2. Do an entrypoint runing nginx from powershell

It translates to this:

CMD [ "powershell", "-c", "C:\nginx\Configure-Nginx.ps1" ]

ENTRYPOINT ["powershell", "C:\nginx\nginx.exe"]
Sign up to request clarification or add additional context in comments.

3 Comments

Will Configure-Nginx.ps1 execute on docker run or docker build? I need it was on docker run.
I've posted a new little modified question that is more detailed. I hope it will help to understand my problem.
Modified answer again :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.