Skip to content

Conversation

@erikh
Copy link
Contributor

@erikh erikh commented Aug 30, 2014

This utilizes a test provided by @cnf which exposed an issue with the parser injecting "" for empty json values, which was then interpreted as a value itself by the evaluator. Removing this exposed a ton of fiddly order-dependent bits around entrypoint and cmd, which then needed to be fixed as well.

Hopefully we can address this with versioning and clarifying semantics.

@erikh
Copy link
Contributor Author

erikh commented Aug 30, 2014

There should be a button at the bottom of each PR that says "watch" or something similar. Click that.

@thaJeztah
Copy link
Member

Oh, sorry for being unclear. I'm watching the whole Docker repo already, so that's not a problem, but I want to relate 'versioning' issues to my proposal, but wasn't really sure 'which way around' I should link; i.e. Link this issue from my issue, or the other way around :)

@erikh
Copy link
Contributor Author

erikh commented Aug 30, 2014

There are going to be at least several dockerfile-related tickets before 1.3 is released; I would prefer they not all be cluttered up this way. The maintainers get a lot of email already.

I appreciate the enthusiasm though and I hope to address versioning soon. :)

On Aug 30, 2014, at 5:04 AM, Sebastiaan van Stijn [email protected] wrote:

Oh, sorry for being unclear. I'm watching the whole Docker repo already, so that's not a problem, but I want to relate 'versioning' issues to my proposal, but wasn't really sure 'which way around' I should link; i.e. Link this issue from my issue, or the other way around :)


Reply to this email directly or view it on GitHub.

@thaJeztah
Copy link
Member

Ok, I'll remove my comment. Thought it could be useful to collect/group version related issues at a central location, but don't want to spam the maintainers obviously. Meanwhile, will keep track on progress and other suggestions are of course welcome!

@LK4D4
Copy link
Contributor

LK4D4 commented Aug 30, 2014

I still don't see cli test on empty entrypoint :)

@vieux
Copy link
Contributor

vieux commented Sep 1, 2014

@LK4D4 👍

@LK4D4
Copy link
Contributor

LK4D4 commented Sep 1, 2014

Also, next tests fails with this PR:

TestCopyVolumeUidGid
TestCopyVolumeContent

@erikh
Copy link
Contributor Author

erikh commented Sep 1, 2014

I have tested these by hand and they do not fail, which makes me think that the tests are busted, and not the code.

Testing master now, will reply in a bit.

-Erik

On Sep 1, 2014, at 11:34 AM, Alexandr Morozov [email protected] wrote:

Also, next tests fails with this PR:

TestCopyVolumeUidGid
TestCopyVolumeContent

Reply to this email directly or view it on GitHub.

@erikh
Copy link
Contributor Author

erikh commented Sep 1, 2014

They don’t fail on master :( I will keep investigating.

On Sep 1, 2014, at 1:11 PM, Erik Hollensbe [email protected] wrote:

I have tested these by hand and they do not fail, which makes me think that the tests are busted, and not the code.

Testing master now, will reply in a bit.

-Erik

On Sep 1, 2014, at 11:34 AM, Alexandr Morozov [email protected] wrote:

Also, next tests fails with this PR:

TestCopyVolumeUidGid
TestCopyVolumeContent

Reply to this email directly or view it on GitHub.

@erikh
Copy link
Contributor Author

erikh commented Sep 1, 2014

Added a test for ENTRYPOINT []. All tests pass except for the two volumes ones.

The reason I’m commenting now is because the behavior might be different.

Now:

When ENTRYPOINT is blank, and CMD is also blank: set ENTRYPOINT to ‘/bin/sh -c’
When ENTRYPOINT is blank, and CMD is set, set ENTRYPOINT to an empty array.

I think this is the desired behavior, but please advise if there was a specific way it was done before.

On Sep 1, 2014, at 1:20 PM, Erik Hollensbe [email protected] wrote:

They don’t fail on master :( I will keep investigating.

On Sep 1, 2014, at 1:11 PM, Erik Hollensbe [email protected] wrote:

I have tested these by hand and they do not fail, which makes me think that the tests are busted, and not the code.

Testing master now, will reply in a bit.

-Erik

On Sep 1, 2014, at 11:34 AM, Alexandr Morozov [email protected] wrote:

Also, next tests fails with this PR:

TestCopyVolumeUidGid
TestCopyVolumeContent

Reply to this email directly or view it on GitHub.

@vieux
Copy link
Contributor

vieux commented Sep 1, 2014

You can't change it or it'll break existing Dockerfiles

@erikh
Copy link
Contributor Author

erikh commented Sep 1, 2014

What is the existing behavior? If I change that code again, other tests will break.

On Sep 1, 2014, at 1:39 PM, Victor Vieux [email protected] wrote:

You can't change it or it'll break existing Dockerfiles


Reply to this email directly or view it on GitHub.

@vieux
Copy link
Contributor

vieux commented Sep 1, 2014

When ENTRYPOINT is blank, and CMD is also blank: set ENTRYPOINT to ‘/bin/sh -c’
This seem really bad, because there is no way to start a binary without sh -c from the cli

@erikh
Copy link
Contributor Author

erikh commented Sep 1, 2014

In TestBuildWithVolumeOwnership, ENTRYPOINT and CMD are inherited and ENTRYPOINT appears to be blank. This test will fail due to varargs in the run command not being processed correctly.

TestBuildNoContext overrides CMD but not ENTRYPOINT, which is also inherited, but from no context. This will break if ENTRYPOINT is blank, which it is in this case because of the busybox image, and since it is a ‘sh -c’ type of CMD. The test will fail complaining of no ‘echo’ in $PATH, which never gets set because sh -c is never run.

These were resolved by the changes in this PR. I’m happy to integrate whatever you want, but as you can see this gets fairly hairy (and these is only a few of the tests). Just let me know what the desired behavior should be, and I’ll try to match it.

On Sep 1, 2014, at 1:45 PM, Victor Vieux [email protected] wrote:

When ENTRYPOINT is blank, and CMD is also blank: set ENTRYPOINT to ‘/bin/sh -c’
This seem really bad, because there is no way to start a binary without sh -c from the cli


Reply to this email directly or view it on GitHub.

@erikh
Copy link
Contributor Author

erikh commented Sep 2, 2014

Just a note on the volume tests — these pass when run independently. I’m wondering if some state is persisting.

Making notes for later, please don’t mind the noise.

On Sep 1, 2014, at 1:51 PM, Erik Hollensbe [email protected] wrote:

In TestBuildWithVolumeOwnership, ENTRYPOINT and CMD are inherited and ENTRYPOINT appears to be blank. This test will fail due to varargs in the run command not being processed correctly.

TestBuildNoContext overrides CMD but not ENTRYPOINT, which is also inherited, but from no context. This will break if ENTRYPOINT is blank, which it is in this case because of the busybox image, and since it is a ‘sh -c’ type of CMD. The test will fail complaining of no ‘echo’ in $PATH, which never gets set because sh -c is never run.

These were resolved by the changes in this PR. I’m happy to integrate whatever you want, but as you can see this gets fairly hairy (and these is only a few of the tests). Just let me know what the desired behavior should be, and I’ll try to match it.

On Sep 1, 2014, at 1:45 PM, Victor Vieux [email protected] wrote:

When ENTRYPOINT is blank, and CMD is also blank: set ENTRYPOINT to ‘/bin/sh -c’
This seem really bad, because there is no way to start a binary without sh -c from the cli


Reply to this email directly or view it on GitHub.

@tianon
Copy link
Member

tianon commented Sep 2, 2014

+1; "sh -c" will definitely break stuff

When the command is finally run, we do a LookupPath on the first item in
the array, which honors $PATH.

@erikh
Copy link
Contributor Author

erikh commented Sep 2, 2014

I’ll review whether PATH is being honored, but I didn’t touch anything in runconfig, so I can’t see why it would change.

On Sep 2, 2014, at 12:04 PM, Tianon Gravi [email protected] wrote:

+1; "sh -c" will definitely break stuff

When the command is finally run, we do a LookupPath on the first item in
the array, which honors $PATH.

Reply to this email directly or view it on GitHub.

@erikh
Copy link
Contributor Author

erikh commented Sep 3, 2014

Ok, this should be ready for merge now; all tests pass. Please review @LK4D4 @tiborvass

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer this as separate test as edge case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, PTAL
On Sep 3, 2014, at 6:15 AM, Alexandr Morozov [email protected] wrote:

In integration-cli/docker_cli_build_test.go:

@@ -766,6 +766,25 @@ func TestBuildEntrypoint(t *testing.T) {
if res != expected {
t.Fatalf("Entrypoint %s, expected %s", res, expected)
}
+

  • deleteImages(name)
  • expected = "[]"
    I prefer this as separate test as edge case.


Reply to this email directly or view it on GitHub.

@erikh
Copy link
Contributor Author

erikh commented Sep 4, 2014

ping @LK4D4 @tianon PTAL, all tests are passing now.

@tiborvass
Copy link
Contributor

@erikh you did not remove the test you extracted, from the original test.

@erikh
Copy link
Contributor Author

erikh commented Sep 4, 2014

lol whoops, fixed now

On Sep 4, 2014, at 1:58 PM, Tibor Vass [email protected] wrote:

@erikh you did not remove the test you extracted, from the original test.


Reply to this email directly or view it on GitHub.

@brauner
Copy link
Contributor

brauner commented Sep 4, 2014

Sorry, but may I chime in here. I have question about this. I'm setting up some Docker containers that run certain programming environments. Hence, I run the containers with the program, say Python, as default entrypoint because I want to be able to call the program with options. But most of the time I just run it without any additional options. That's why I specify in the Dockerfiles:

CMD [" "]
ENTRYPOINT ["/usr/bin/python"]

This allows me to run the programm either with or without options. Should I do this differently now? If so I would change this pretty soon should Docker break this behaviour at some point.

@tiborvass
Copy link
Contributor

@lord-garbage

  1. Right now, you don't need the empty CMD trick, if you're not doing FROM image where image already has a CMD set.
  2. In Docker 1.3, you won't need the empty CMD trick at all.
  3. I note that you did CMD [" "] with a space between the double quotes. Don't you have the same behavior without the space? @erikh can we make sure we handle the case with the space? I guess we expect (cmd " ").

@erikh
Copy link
Contributor Author

erikh commented Sep 4, 2014

I can write a test

@brauner
Copy link
Contributor

brauner commented Sep 5, 2014

My bad, I don't actually have CMD [" "]. Instead I have CMD []. And I have the FROM part set.

@tiborvass
Copy link
Contributor

LGTM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this check happen earlier?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no. unless I'm misunderstanding you, this is propagated from the parser, so there will only be one argument if the CMD was not json encoded.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well you are consuming the value in args = append([]string{b.image}, args...) then later checking if it is == "" before erroring out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohhh. ok. I'll fix it rihgt away.

Erik Hollensbe added 2 commits September 11, 2014 06:00
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <[email protected]> (github: erikh)
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <[email protected]> (github: erikh)
Erik Hollensbe added 6 commits September 11, 2014 06:00
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <[email protected]> (github: erikh)
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <[email protected]> (github: erikh)
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <[email protected]> (github: erikh)
autoConfig seeding of entrypoint.

Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <[email protected]> (github: erikh)
… function

Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <[email protected]> (github: erikh)
dispatcher

Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <[email protected]> (github: erikh)
@erikh
Copy link
Contributor Author

erikh commented Sep 11, 2014

@crosbymichael last commit fixes your concerns.

@crosbymichael
Copy link
Contributor

LGTM

@crosbymichael
Copy link
Contributor

@erikh is there an issues that this fixes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants