Skip to content
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

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

Merged
merged 1 commit into from Nov 4, 2015

Conversation

sallyom
Copy link
Contributor

@sallyom sallyom commented Jun 18, 2015

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
Copy link
Contributor

rhatdan commented Jun 18, 2015

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

@LK4D4
Copy link
Contributor

LK4D4 commented Jun 25, 2015

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

@tiborvass
Copy link
Contributor

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

@sallyom
Copy link
Contributor Author

sallyom commented Jul 7, 2015

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
Copy link
Contributor

rhatdan commented Jul 8, 2015

@crosbymichael
Copy link
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
Copy link
Contributor

rhatdan commented Jul 8, 2015

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
Copy link
Contributor Author

sallyom commented Jul 17, 2015

will this be considered before Docker 1.8?

@rhatdan
Copy link
Contributor

rhatdan commented Jul 17, 2015

@cpuguy83
Copy link
Member

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

@thaJeztah
Copy link
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
Copy link
Contributor

icecrime commented Nov 4, 2015

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

@sallyom
Copy link
Contributor Author

sallyom commented Nov 4, 2015

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

@@ -518,6 +518,38 @@ non-zero exit status more than 10 times in a row Docker will abort trying to
restart the container. Providing a maximum restart limit is only valid for the
**on-failure** policy.

## Exit Status

The exit code from `docker run` will give information about why the container
Copy link
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
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
Copy link
Contributor Author

sallyom commented Nov 4, 2015

@thaJeztah done!

@calavera
Copy link
Contributor

calavera commented Nov 4, 2015

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

@thaJeztah
Copy link
Member

Oh cool, it's updated, thanks!!

LGTM \o/

thaJeztah added a commit that referenced this pull request Nov 4, 2015
Change 'docker run' exit codes to distinguish docker/contained errors
@thaJeztah thaJeztah merged commit 236913f into moby:master Nov 4, 2015
@sallyom
Copy link
Contributor Author

sallyom commented Nov 5, 2015

woohoo!

@cpuguy83
Copy link
Member

cpuguy83 commented Nov 5, 2015

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

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

@runcom
Copy link
Member

runcom commented Nov 5, 2015

@sallyom thanks! and great job!

@thaJeztah thaJeztah added this to the 1.10 milestone Nov 30, 2015
awh added a commit to weaveworks/weave that referenced this pull request Jan 20, 2016
rade pushed a commit to weaveworks/weave that referenced this pull request Jan 21, 2016
awh added a commit to weaveworks/weave that referenced this pull request Mar 2, 2016
motiejus added a commit to motiejus/systemd-docker that referenced this pull request Jan 3, 2018
As of Docker 1.10.0
([#14012](moby/moby#14012)), the exit code
for incorrect command-line arguments is 125.
motiejus added a commit to motiejus/systemd-docker that referenced this pull request Jan 15, 2018
As of Docker 1.10.0
([#14012](moby/moby#14012)), the exit code
for incorrect command-line arguments is 125.
nasuku pushed a commit to nasuku/systemd-docker that referenced this pull request Jan 16, 2018
As of Docker 1.10.0
([#14012](moby/moby#14012)), the exit code
for incorrect command-line arguments is 125.
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