Open DavidSimner opened 5 years ago
~$ docker import --change "ENTRYPOINT [ '/sbin/init' ]" my.tar sd
sha256:8b012fc409b607ed36d8b2ffeeb94f7699bb7452419848adad51ecee7813e0f3
~$ docker inspect 8b012fc409 -f '{{.Config.Entrypoint}}'
[/bin/sh -c [ '/sbin/init' ]]
~$ docker import --change 'ENTRYPOINT [ "/sbin/init" ]' my.tar ds
sha256:affa3d50ebdd60d05061f94d772278fa21ae979c782a62e76c9b5e6dd63dc0ea
~$ docker inspect affa3d50ebdd60d050 -f '{{.Config.Entrypoint}}'
[/sbin/init]
I step into a similar situation on s390x
, and found that the single and dounle quote mark on the change command makes quite a difference here, with "
the entrypoint would be called by /bin/sh
Description From PowerShell on Windows, I'm trying to use
docker import
to create a new image from a tarball, and I'm using its--change
command line option to set theENTRYPOINT
of the newly created image. I would like the newly created image to use an execENTRYPOINT
and I think that I'm specifying that, but when the image is created, it is for some reason using a shellENTRYPOINT
The root cause is that PowerShell's rules for escaping command line characters on Windows are particularly complicated to understand, and it would be nice if an exec
ENTRYPOINT
could be specified with'
as well as the existing"
. By allowing'
it would make it easier for Windows PowerShell users to craft command lines.Steps to reproduce the issue: Create a tarball, then import it. In these minimal repro steps the tarball isn't a valid image for a container that can start, but these steps are sufficient to demonstrate the issue, and the bug also happens for real images (feel free to use a different tarball if you have one to hand).
echo Hello >world.txt
tar -cf tarball.tar world.txt
docker import --change "ENTRYPOINT [""cat"", ""world.txt""]" tarball.tar
docker inspect
the image that you just created (docker import outputs to stdout the sha256 hash that you need to use), for example on my machine it wasdocker inspect sha256:d07c694f5b035edd8c87df2a6c0087a4ca866f8b0958b1d6edcedeaae44bac4b
(yours will be different because the modified date of the file will be different)Describe the results you received:
docker inspect
will output a lot of JSON andENTRYPOINT
is mentioned twice; ignore the mention inContainerConfig
because it isn't relevant for us, and instead look at the mention inConfig
which is:Describe the results you expected: The results that I received above demonstrate that, even though the command line switch specified an exec
ENTRYPOINT
, it has been incorrectly specified as a shellENTRYPOINT
in the image that was created.Instead of the above, I expected the JSON to contain:
If instead I replace step 3 above with
docker import --change 'ENTRYPOINT [""""cat"""", """"world.txt""""]' tarball.tar
then it works, but it's not easy to understand that I need to craft a command line like that, so it'd be good if Docker could provide more help either via documentation or allowing more flexibility toENTRYPOINT
.Output of
docker version
:Output of
docker info
:Additional environment details (AWS, VirtualBox, physical, etc.): Physical laptop