-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Images with ENTRYPOINT set can't expand environment variables in command #2316
Comments
This is a place where docker is, IMO, over-flexible to the point of On Tue, Nov 11, 2014 at 7:19 PM, Clayton Coleman notifications@github.com
|
I don't expect content paths to change much, and if you specify your own cmd you're implicitly saying you know what arguments you're providing to a command and hence know the location. If we do 3 we might introduce a flag in v1beta1/2 and then swap the behavior in 3 (no more entrypoint). Or we can just break entrypoints with commands now.
|
See also #1710. |
/cc @erictune |
Related: Users find it confusing for Docker supports:
Do they really support two different json data types using the same field names? We shouldn't do that, but I do think we need to make this easier to use. I could imagine supporting argv (array), command (string), and overrideContainerCommand (bool that indicates the entrypoint string should be set instead of cmd). If the user wants control over which shell to invoke, they always should have the option of Kubelet should be able to inspect the container image to determine whether /bin/sh exists. If it doesn't, there are 2 options: (1) fail and generate an event that indicates permanent failure, or (2) bind-mount a shell into the container. |
On Tue, Jan 13, 2015 at 12:15 PM, bgrant0607 notifications@github.com wrote:
They really do support 3 different ways to specify commands, and no I can see us accepting []string or string for command (not that hard I don't see a way for us to override Docker's entrypoint without a
IMO this should ALWAYS have been the API.
I think (2) is dubious, and (1) is unneeded. Just pass it in and fail |
My interpretation is the following:
The crossproduct is more than 3 ways. I don't want to screw up our automatic json parsing, so if we support both the array and string, they should be separate fields. I suppose we can deal with crashlooping in the same manner as a non-existent image. The only way to fix it would be to update the command or push a new image (and maybe explicitly update to the new image tag), but I suppose that's ok, provided we do have a way to notify the user and gracefully back off. |
On Tue, Jan 13, 2015 at 3:30 PM, bgrant0607 notifications@github.com wrote:
I decided to do an experiment to see what the cross-product really is. https://gist.github.com/thockin/c44a88b84c2a1041a1bd
That's awful. It's not consistent with docker's docs and it is often
I don't get this. It's relatively easy to write a receiving type that
|
Harder to write clients for api fields that can change type, especially if we don't normalize it when we send it in a response (be strict in what you output, generous in what you accept etc). Entry point I think makes a lot of sense for most users - it's "container as user experience" or "container as binary". We found the Openshift image works better that way (because client and server are in the same binary). I'd really like to preserve the idea of the default executable (which is really the shell). Maybe we should assume every image has an entry point, and split command into "executable" and "arguments"
|
The issue I have with entrypoint is not that it doesn't make sense, but If we split command[] into argv0 and args, I guess it's a bit clearer, but On Tue, Jan 13, 2015 at 4:50 PM, Clayton Coleman notifications@github.com
|
The Kubelet can hide that though when the container is invoked (given the image must be pulled). I guess I'm proposing there only be one option, and we enforce "what users get".
|
Among other things, Swagger has trouble with custom types: #2971. |
What do you mean "hide that"? If I have a container with no entrypoint and On Tue, Jan 13, 2015 at 5:11 PM, Clayton Coleman notifications@github.com
|
We should not limit our UX by shortcomings in tools. On Tue, Jan 13, 2015 at 5:14 PM, bgrant0607 notifications@github.com
|
Personally, I'd prefer separate argv and command fields. Overloading a single field is confusing and error-prone. I'm all for trying to fix it, but if we can't make the swagger work, it will degrade the UX in other ways, through incorrect documentation, validation, and configuration transformations. |
Let's figure out what we thing sane semantics are, then debate how to As it is, we either do what docker does - two fields with On Tue, Jan 13, 2015 at 5:21 PM, bgrant0607 notifications@github.com
|
We should at least return what command was executed in container status so users can debug what went wrong. |
I'm ok with some restrictions, especially if there's an escape hatch. But we do need to make containers with entrypoints work. I've used them and agree they are convenient. One option could be to do podex-like expansion in the client and build the command there. Kubelet could always clear entrypoint (empty array?). Would kind of suck for direct API usage, though. |
now THAT I can get behind :) On Tue, Jan 13, 2015 at 5:25 PM, bgrant0607 notifications@github.com
|
Maybe it wouldn't be so bad to simply say we have 2 fields, argv0 and Then we have to answer the question of bare-string (not array) commands. On Tue, Jan 13, 2015 at 5:27 PM, bgrant0607 notifications@github.com
|
/bin/sh "foo" "bar". If you have entry point, entrypoint "foo" "bar"
|
Why is sh involved? If command is an array, there should be no shell at My main gripe is that I do not see a semantic that a) makes some semblance On Tue, Jan 13, 2015 at 5:45 PM, Clayton Coleman notifications@github.com
|
@thockin My bad, 'docker entrypoint/cmd' is the entrypoint and container of the actual docker container created |
Thoughts on matrix:
|
Please god no |
That's why I (slightly) prefer a different API block - no escaping rules |
I don't see us ever changing env to a map. It's not worth it. Whether a separate field like Generate or a different API block, I don't see why we need escaping. I don't think we should support arbitrary expansion, just straight copying of the specified field. As for Command/Args in v1beta1/2 -- maybe introduce a new Entrypoint field and leave Command as is? Hopefully these versions will be gone soon, anyway. They just need to not lose information when roundtripping. |
If we overlap the same API block, we need escaping. what if I want On Fri, Mar 27, 2015 at 9:31 AM, Brian Grant notifications@github.com
|
I think that's a good thing, because order always matters in ENV resolution. ----- Original Message -----
|
My proposal though was there were two fields in the EnvVar, one for normal, unqualified escaping (handled by docker), and one for generated / downward api fields. The two were exclusive, and non-overlapping. ----- Original Message -----
|
...which is just a different factoring than being in a different API block, I'm fine either way - we can always rev the API later :) On Fri, Mar 27, 2015 at 9:44 AM, Clayton Coleman notifications@github.com
|
@thockin I am surprised given your general distaste for env vars that would would want to make that big of an API change around them :) |
@smarterclayton has a good point about ordering. |
One of the things that annoys me more than env vars is awkward APIs :) |
Why does order matter? We don't do cross-env resolution (AFAIK) |
That is a good idea. |
@yifan-gu I see that you moved |
Order matters when Docker resolves things. Or if someone else implements an ordered algorithm. If you don't have that clear ordering then you don't have consistent resolution.
|
@pmorie Thanks for the notification. I think there is still a FYI, here is a related discussion: |
@smarterclayton @bgrant0607 Can this issue be closed now that #6100 has landed? |
Yes. |
The network test failure made me wonder: do we need to distinguish between unspecified command/args and empty command/args? How would I clear the CMD specified in the image? |
@bgrant0607, as in, you want to run the default entrypoint without any On Wed, Apr 1, 2015 at 1:02 PM, Brian Grant notifications@github.com
|
I'm not saying I want to do that, but that's the scenario I was thinking about, yes. |
@bgrant0607 The way you would have to do it currently is manually specify On Wed, Apr 1, 2015 at 1:27 PM, Brian Grant notifications@github.com
|
To expand environment variables, the command for a pod must use
sh
-command: ["sh", "-c", "${MYVAR}"]
. However, images with an entrypoint will not be able to use this technique, because the command array is then appended to the ENTRYPOINT instead of replacing the CMD.Saying that images with entry points can't do variable expansion seems too limiting. We have no technique to allow a consumer to solve that problem. Assuming that entrypoint is here to stay and an image consumer may want to either replace variables OR override the entrypoint, there are a few options:
a. Add an option to command to treat the command as an override to entrypoint. Backwards compatible.
b. Add a fake environment var to be evaluated prior to container start that substitutes the images entrypoint (`command: ['sh', '-c', '${ENTRYPOINT}', ...]')
3 seems the most consistent (don't allow entry points) with the minor inconvenience of ignoring the preferred path of the image author. 3a seems crufty. 3b is very crufty. 1, 2, and 4 seem very crufty.
The text was updated successfully, but these errors were encountered: