Skip to content

Change 'docker run' exit codes to distinguish docker/contained errors - #14012

Merged
thaJeztah merged 1 commit into
moby:masterfrom
sallyom:exitCodes
Nov 4, 2015
Merged

Change 'docker run' exit codes to distinguish docker/contained errors#14012
thaJeztah merged 1 commit into
moby:masterfrom
sallyom:exitCodes

Conversation

@sallyom

@sallyom sallyom commented Jun 18, 2015

Copy link
Copy Markdown
Contributor

close #6734

The purpose of this PR is for users to distinguish Docker errors from
contained command errors.
This PR modifies 'docker run' exit codes to follow the chroot standard
for exit codes.
Exit status:
125 if 'docker run' itself fails
126 if contained command cannot be invoked
127 if contained command cannot be found
the exit status otherwise

Signed-off-by: Sally O'Malley somalley@redhat.com

@rhatdan

rhatdan commented Jun 18, 2015

Copy link
Copy Markdown
Contributor

We are basing this off of the "defacto" chroot standard. Bash has some rules around this also.

@LK4D4

LK4D4 commented Jun 25, 2015

Copy link
Copy Markdown
Contributor

looks ok for me.
ping @docker/core-maintainers

@tiborvass

Copy link
Copy Markdown
Contributor

@sallyom @LK4D4 Also see #13907 that just got merged

@sallyom

sallyom commented Jul 7, 2015

Copy link
Copy Markdown
Contributor Author

Any word on this?

@sallyom
sallyom force-pushed the exitCodes branch 4 times, most recently from 6459251 to 9267e33 Compare July 8, 2015 12:16
@rhatdan

rhatdan commented Jul 8, 2015

Copy link
Copy Markdown
Contributor

@crosbymichael

Copy link
Copy Markdown
Contributor

I think this is a good idea. Do you think we would break anyone relying on the existing error codes or do you think they are just checking for a non-zero return?

@rhatdan

rhatdan commented Jul 8, 2015

Copy link
Copy Markdown
Contributor

I would doubt anyone would check on this, but if they were that would be a bug in their code. Currently you can not differentiate between docker errors and errors in apps in containers, so looking for exit code of 1 makes little sense.

@sallyom
sallyom force-pushed the exitCodes branch 4 times, most recently from 5c38be1 to 0698333 Compare July 17, 2015 19:33
@sallyom

sallyom commented Jul 17, 2015

Copy link
Copy Markdown
Contributor Author

will this be considered before Docker 1.8?

@rhatdan

rhatdan commented Jul 17, 2015

Copy link
Copy Markdown
Contributor

@cpuguy83

Copy link
Copy Markdown
Member

+1 makes sense. Moving to code review since @crosbymichael seemed to be ok with it as well.

Comment thread pkg/integration/utils.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you explain this code here? If we have to check the output error message to "calculate" the exit code, then isn't something wrong since I thought the point of this PR was to make sure our exit codes were set properly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not ignoring this, just looking into it more to compare to derr.Errs...not very easy to test this package, actually.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@duglin as I (now) understand it the pkg/integration is to set up/test the utilities used in integration-cli, so there's no need to add tests or change anything there. The new exit codes are tested in int-cli. Thnx for your patience :)

@sallyom

sallyom commented Oct 5, 2015

Copy link
Copy Markdown
Contributor Author

working on feedback now, I've fixed the 'image doesn't not exist' errors by adding a similar check in api/client/run.go for the already existing derr.ErrorCodeNoSuchImageHash and derr.ErrorCodeNoSuchImageTag errors that were created in daemon/create.go --should have seen this before :( working on other feedback now....

@sallyom

sallyom commented Oct 14, 2015

Copy link
Copy Markdown
Contributor Author

@LK4D4 @cpuguy83 I've addressed all feedback, thanks for giving it another look.
@duglin, see my response about the pkg/integration (no changes necessary)
thanks :)

Comment thread api/client/run.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm thinking the 2nd param should be false here.

$ docker run -ti ubuntu /tmp
exec: "/tmp": permission denied
docker: Error response from daemon: Contained command could not be invoked..
See '/root/docker/bundles/1.9.0-dev/binary/docker run --help'.

I think it makes sense to show the short help message in cases where we think there might be a docker specific error on the cmd line (like a bad option), but in cases where we've made it all the way to the container.start() we're probably into the user (or cmd) space and so I'm not sure showing the help message helps. Keeping it on the parsing error and create error, above, are ok though.

@duglin

duglin commented Oct 14, 2015

Copy link
Copy Markdown
Contributor

overall looks good - just a couple of minor comments

@sallyom

sallyom commented Oct 15, 2015

Copy link
Copy Markdown
Contributor Author

@duglin, addressed your comments, thanks again.

@duglin

duglin commented Oct 15, 2015

Copy link
Copy Markdown
Contributor

LGTM!

@sallyom

sallyom commented Oct 15, 2015

Copy link
Copy Markdown
Contributor Author

ping @LK4D4 @cpuguy83, anything else? Thanks :)

@bfirsh

bfirsh commented Oct 21, 2015

Copy link
Copy Markdown
Contributor

ping @jfrazelle @tiborvass look good?

@calavera

calavera commented Nov 2, 2015

Copy link
Copy Markdown
Contributor

LGTM.

I'm rerunning the build before merging it to make sure this change doesn't break anything after so many changes.

@sallyom

sallyom commented Nov 3, 2015

Copy link
Copy Markdown
Contributor Author

@calavera anything else?

@thaJeztah

Copy link
Copy Markdown
Member

Hm, does this need documentation changes somewhere? I'm not sure actually if we mention exit-codes somewhere in the docs

@thaJeztah

Copy link
Copy Markdown
Member

I counted two LGTM's, moving to docs review (but I'm not actually sure we have something around this, so suggestions are welcome)

@icecrime

icecrime commented Nov 4, 2015

Copy link
Copy Markdown
Contributor

It's a good feature, I believe it should be documented indeed!

@sallyom

sallyom commented Nov 4, 2015

Copy link
Copy Markdown
Contributor Author

@thaJeztah @icecrime in man/docker-run.1.md and docs/reference/run.md? I'm on it :)

Comment thread docs/reference/run.md Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

small nit: s/will give/gives/

@thaJeztah

Copy link
Copy Markdown
Member

in man/docker-run.1.md and docs/reference/run.md? I'm on it :)

sgtm! I see you added to reference/run.md, not yet in the man page

looks like this needs to be squashed and rebased as well (don't shoot the messenger! 😄)

The purpose of this PR is for users to distinguish Docker errors from
contained command errors.
This PR modifies 'docker run' exit codes to follow the chroot standard
for exit codes.
Exit status:
125 if 'docker run' itself fails
126 if contained command cannot be invoked
127 if contained command cannot be found
the exit status otherwise

Signed-off-by: Sally O'Malley <somalley@redhat.com>
@sallyom

sallyom commented Nov 4, 2015

Copy link
Copy Markdown
Contributor Author

@thaJeztah done!

@calavera

calavera commented Nov 4, 2015

Copy link
Copy Markdown
Contributor

thanks @sallyom. Man LGTM too. @thaJeztah can you check it out and merge if it looks good to you?

@thaJeztah

Copy link
Copy Markdown
Member

Oh cool, it's updated, thanks!!

LGTM \o/

@sallyom

sallyom commented Nov 5, 2015

Copy link
Copy Markdown
Contributor Author

woohoo!

@cpuguy83

cpuguy83 commented Nov 5, 2015

Copy link
Copy Markdown
Member

/me waits for the world to burn with this one :)

This is a good change though, I like having distinct exit codes.

@runcom

runcom commented Nov 5, 2015

Copy link
Copy Markdown
Member

@sallyom thanks! and great job!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docker run exit code consisency