RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1097344 - Docker run exit code consistency
Summary: Docker run exit code consistency
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: docker-latest
Version: 7.0
Hardware: x86_64
OS: Linux
medium
high
Target Milestone: rc
: ---
Assignee: Lokesh Mandvekar
QA Contact: atomic-bugs@redhat.com
URL:
Whiteboard:
: 1097334 (view as bug list)
Depends On:
Blocks: docker-1.10
TreeView+ depends on / blocked
 
Reported: 2014-05-13 15:17 UTC by Chris Evich
Modified: 2016-05-12 14:52 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1162807 (view as bug list)
Environment:
Last Closed: 2016-05-12 14:52:52 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2016:1057 0 normal SHIPPED_LIVE new packages: docker-latest 2016-05-12 18:51:24 UTC

Description Chris Evich 2014-05-13 15:17:50 UTC
Description of problem:
The docker run operation should never return a non-zero exit code.

Version-Release number of selected component (if applicable):
docker-0.10.0-10.el7.x86_64

How reproducible:
very

Steps to Reproduce:
1. # docker run fedora:20 /bin/false; echo $?
2. # docker run this_image_does_not_exist /bin/false; echo $?

Actual results:
# docker run fedora:20 /bin/false; echo $?
1
Unable to find image 'this_image_does_not_exist' locally
Pulling repository this_image_does_not_exist
2014/05/13 11:08:53 HTTP code: 404
1

Expected results:
Unable to find image 'this_image_does_not_exist' locally
Pulling repository this_image_does_not_exist
2014/05/13 11:08:53 HTTP code: 404
0

Additional info:
If docker CLI and contained-process both return exit code 1, how is automated control of 'docker run' to tell the difference (other than by examining error messages).  See also Bug 1097334

Additional Additional info:
Marking this high because it affects CI, just as 1097334.  One or the other should be fixed ASAP.

Comment 1 Daniel Walsh 2014-05-19 18:03:26 UTC
Not sure what to do here.  I would guess that you do not want the exit codes from within the container to return to $?

docker run --rm fedora sh -c 'exit 2'; echo $?
2

But I think this is expected.

Comment 2 Chris Evich 2014-05-19 20:41:14 UTC
(In reply to Daniel Walsh from comment #1)
> Not sure what to do here.  I would guess that you do not want the exit codes
> from within the container to return to $?
> 
> docker run --rm fedora sh -c 'exit 2'; echo $?
> 2
> 
> But I think this is expected.

See https://bugzilla.redhat.com/show_bug.cgi?id=1097334#c3 and https://bugzilla.redhat.com/show_bug.cgi?id=1097334#c4

Comment 3 Daniel Walsh 2014-06-27 16:42:07 UTC
chroot command has a close relationship to this

  Exit status:

     125 if 'chroot' itself fails
     126 if COMMAND is found but cannot be invoked
     127 if COMMAND cannot be found
     the exit status of COMMAND otherwise

Comment 4 Daniel Walsh 2014-06-27 16:42:31 UTC
I have raised this issue with upstream


https://github.com/dotcloud/docker/issues/6734

Comment 5 Chris Evich 2014-06-27 17:57:09 UTC
Great, I really like your idea of mirroring chroot's behavior, I think that's the right way to go.  It also makes documentation easy, 'see also chroot's exit status' :D

This will make testing efforts easier as well, since we can quickly/easily distinguish problems coming from docker or the container.

Comment 6 Daniel Walsh 2014-06-27 19:24:22 UTC
Please comment on the issues

Comment 8 Chris Evich 2015-01-27 17:15:30 UTC
Just to clarify:

This bug is strictly for the run sub-command, since it needs special treatment. This issue is pretty important IMHO.

Bug 1162807 is about non-run sub-commands, It's verified fixed in 1.4.1-25.

Bug 1097334 is for all sub-commands not using consistent language in error/warning messages.  Minor issue.

Comment 10 Daniel Walsh 2015-04-14 19:55:00 UTC
shishir is this working in docker-1.6?

Comment 12 Sally 2015-07-07 18:52:58 UTC
*** Bug 1097334 has been marked as a duplicate of this bug. ***

Comment 15 Sally 2015-09-03 08:33:58 UTC
There is a pending PR for this, https://github.com/docker/docker/pull/14012.  The PR has gotten positive response, waiting for merge.

Comment 19 Daniel Walsh 2015-12-01 21:52:56 UTC
Fixed in docker-1.10/

Comment 20 Chris Evich 2015-12-02 16:36:32 UTC
Added note to https://trello.com/c/wK1SIihn for CI testing.

Comment 26 Daniel Walsh 2016-03-22 17:00:09 UTC
Yes lets wait for docker-1.10 to say this is fixed.

Comment 29 Luwen Su 2016-05-02 09:27:11 UTC
In docker-latest-1.10.3-19.el7.x86_64, there is a group of specified error code
see https://github.com/docker/docker/pull/14012/files,

Note:Use ``docker-latest`` instead of ``docker``

# docker-latest run this_image_does_not_exist /bin/false; echo $?
Unable to find image 'this_image_does_not_exist:latest' locally
Trying to pull repository docker.io/library/this_image_does_not_exist ... 
Pulling repository docker.io/library/this_image_does_not_exist
Error: image library/this_image_does_not_exist not found
docker: Error: image library/this_image_does_not_exist not found.
See 'docker-latest run --help'.
125

# docker-latest run busybox /etc; echo $?
exec: "/etc": permission denied
docker: Error response from daemon: Container command could not be invoked..
126

# docker-latest run busybox foo; echo $?
exec: "foo": executable file not found in $PATH
docker: Error response from daemon: Container command not found or does not exist..
127

# docker-latest run busybox /bin/sh -c 'exit 3' 
# echo $?
3

Comment 30 Chris Evich 2016-05-02 14:04:45 UTC
FYI there is still some minor inconsistent behaviour: ref: bug 1331575

Comment 32 errata-xmlrpc 2016-05-12 14:52:52 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHEA-2016-1057.html


Note You need to log in before you can comment on or make changes to this bug.