fix(cli): keep --entrypoint a single token, matching Docker - #89
Merged
Conversation
`run`, `create` and `compose run` split the `--entrypoint` value on
spaces and spliced the extra tokens ahead of the command argv. Docker
does not do this: docker/cli wraps the flag value in a single-element
slice (`entrypoint = []string{copts.entrypoint}`), so
`--entrypoint "/bin/sh -c"` is one executable path there and fails to
launch.
The splitting made mocker accept input Docker rejects, and broke the
legitimate case of an entrypoint path that contains a space. Pass the
value through untouched; the Docker way of supplying entrypoint args
(`--entrypoint /bin/sh image -c "..."`) already works.
Compose service `entrypoint:` handling is unaffected: it is a real list
and still resolves through `ComposeOrchestrator.resolveExec`.
Contributor
|
thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #85, which landed the compose
entrypoint:support (thanks @itxtoledo). That PR also changed the--entrypointCLI flag onrun,createandcompose runto split its value on spaces and splice the extra tokens ahead of the command argv. This reverts that part; the compose fix stays.Why
Docker does not split
--entrypoint.docker/cliwraps the flag value in a single-element slice:So in Docker,
--entrypoint "/bin/sh -c"is one executable path and fails to launch. Splitting made mocker accept input Docker rejects, and broke an entrypoint path that legitimately contains a space (/opt/my app/run.shwas silently torn into two argv elements).The Docker way of passing entrypoint arguments already works and is unchanged:
Changes
Run.swift,Create.swift,Compose.swift(compose run): pass--entrypointthrough untouched. Pure deletion, 3 files, -30/+6.entrypoint:is unaffected. It is a real list and still resolves throughComposeOrchestrator.resolveExec, which keeps the DockerENTRYPOINT + CMDconcatenation within Applecontainer's single-token--entrypointconstraint.Verification
swift buildclean,swift test454 tests pass.Against the real runtime:
mocker run --entrypoint /bin/sh alpine -c "echo DOCKER_FORM_OK"->DOCKER_FORM_OKmocker run --entrypoint "/bin/echo hi" alpine->failed to find target executable /bin/echo hi(same as Docker; previously it silently succeeded)mocker compose up -dwithentrypoint: ["/bin/sh", "-c"]+command:-> container up, logs show the expected outputCompatibility
No behavior that worked before #85 changes. The only thing removed is the space-splitting introduced by #85, which is not in any release yet.