-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support PowerShell as ENTRYPOINT for Docker builds #8225
Comments
Thanks for opening! I took a quick look and Packer doesn't modify that "changes" field at all -- we just pass the changes straight through into the driver call. I wonder if this is prepending is something intrinsic to Docker? I'm not sure when I'm going to have a chance to do a deep dive, but if you get a chance to run the commit call from the command line instead of letting Packer do it, we may learn what's going on here. |
That's odd. At first, it looked like Packer appends the prefix - sorry for the assumption. I'll immediately test the command line commit tomorrow and add the missing information. |
@SwampDragons I did some tests and found following GitHub issue and explanation.
It looks like Packer pass the changes in shell form instead of exec form to Docker. Even
creates the entrypoint in shell form. A Dockerfile instead creates exec form. Do you have an idea, how to setup the parameter to commit the image in exec form? |
hmm. Have you tried just providing that form? the code that handles this is just https://github.com/hashicorp/packer/blob/master/builder/docker/driver_docker.go#L53-L55 That may not be enough if we have to have that '=' sign in there. If we do, updating this code to check for the syntax shouldn't be too tough. |
Ok, I got it. It's important to use the exec form for
Nevertheless, I suggest to update the documentation:
If you like, I can create a PR. |
That makes sense to me. I'd love that PR. |
…ntation-docker-shell-exec-form #8225 Add Docker shell and exec format documentation for CMD and ENTRYPOINT
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Feature Description
Packer uses CMD (
cmd.exe
) as default command-line shell for Docker Windows container and appendscmd /S /C
to eachENTRYPOINT
orCMD
. This behavior makes it impossible to execute a PowerShell asENTRYPOINT
and run a PowerShell command withCMD
in it (without nested shells).I think the user should decides in the Packer configuration which shell he or she wants to use, equivalent to the Dockerfile. Packer should not append the prefix
cmd /S /C
automatically.Use Case(s)
PowerShell is de facto the default command-line shell for Windows. Compared to CMD, PowerShell supports a lot more features.
Additional Information
This Docker configuration in Packer:
creates following Docker image configuration:
This will execute
cmd.exe
>powershell.exe
>cmd.exe
> 💥, becausecmd.exe
dose not know the PowerShell commandWrite-Host
. I also tried to set SHELL, but this is not supported either by Packer.The text was updated successfully, but these errors were encountered: