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 1162807 - Docker CLI exit codes for errors?
Summary: Docker CLI exit codes for errors?
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: docker
Version: 7.0
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: rc
: ---
Assignee: smahajan@redhat.com
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-11-11 18:00 UTC by Chris Evich
Modified: 2019-03-06 02:02 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of: 1097344
Environment:
Last Closed: 2015-03-05 03:19:07 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2015:0623 0 normal SHIPPED_LIVE Low: docker security, bug fix, and enhancement update 2015-03-05 15:28:35 UTC

Description Chris Evich 2014-11-11 18:00:19 UTC
+++ This bug was initially created as a clone of Bug #1097344 +++

Description of problem:
Non-run docker CLI operations should return non-zero exit code along with error messages.  Alternatively, the "chroot" method here https://github.com/dotcloud/docker/issues/6734 would also be acceptable.

Version-Release number of selected component (if applicable):
docker-1.3.0-5.el7.HTB.x86_64

How reproducible:
Trivial

Steps to Reproduce:
1. # /usr/bin/docker -D attach --no-stdin=sig-proxy
2. # /usr/bin/docker -D commit --authormessage 123412341234 <container name>

Actual results:
Exit code: 0
Standard Out: """"""
Standard Error: """invalid boolean value "sig-proxy" for  --no-stdin: strconv.ParseBool: parsing "sig-proxy": invalid syntax
See 'docker attach --help'.
"""

Exit code: 0
Standard Out: """"""
Standard Error: """flag provided but not defined: --authormessage
See 'docker commit --help'.
"""

Expected results:
Exit code: <non-zero>
Standard Out: """"""
Standard Error: """invalid boolean value "sig-proxy" for  --no-stdin: strconv.ParseBool: parsing "sig-proxy": invalid syntax
See 'docker attach --help'.
"""

Exit code: <non-zero>
Standard Out: """"""
Standard Error: """flag provided but not defined: --authormessage
See 'docker commit --help'.
"""

Additional info:

Some CLI commands actually do return non-zero, for example:

# /usr/bin/docker -D load --input

Exit code: 1
Standard Out: """"""
Standard Error: """flag needs an argument: --input
See 'docker load --help'.
[2014-11-11T12:30:25.736050885-05:00] [fatal] log.go:64 flag needs an argument: --input
"""

Comment 2 smahajan@redhat.com 2014-11-21 20:38:39 UTC
These 3 commands are providing an exit code of 2 (Non-zero exit code for failure), so they are working as expected.

1) # /usr/bin/docker -D attach --no-stdin=sig-proxy
   echo $?
   Prints: 2
2. # /usr/bin/docker -D commit --authormessage 123412341234 <container name>
   echo $?
   Prints: 2
3) docker load --input
   Prints: flag needs an arguement: --input
   echo $?
   Prints: 2

however HELP commands are throwing non-zero (2) exit code.

e.g. docker --help
     docker run --help
     docker pull --help

These commands should throw exit code 0 (SUCCESS).
So I ll keep this ticket open for now.

Shishir

Comment 3 Daniel Walsh 2014-11-21 20:57:41 UTC
There is an existing pull request to fix the docker --help issue.

Comment 4 smahajan@redhat.com 2014-11-24 15:09:57 UTC
For --help issue this is the PR being worked on.
https://github.com/docker/docker/pull/9085

Closing the ticket now.

Shishir

Comment 5 Chris Evich 2014-11-24 16:15:25 UTC
Hi,

There must be some discrepancy or mistake I am making then.

[root@dockertest ~]# yum update
Loaded plugins: product-id, subscription-manager
No packages marked for update
[root@dockertest ~]# docker version
Client version: 1.3.0
Client API version: 1.15
Go version (client): go1.3.1
Git commit (client): 16a7d74/1.3.0
OS/Arch (client): linux/amd64
Server version: 1.3.0
Server API version: 1.15
Go version (server): go1.3.1
Git commit (server): 16a7d74/1.3.0

With docker-1.3.0-5.el7.HTB.x86_64 (i.e. CURRENTRELEASE) I'm still getting a zero exit code, even copy-paste from your commands above:

[root@dockertest ~]# /usr/bin/docker -D attach --no-stdin=sig-proxy; echo $?
invalid boolean value "sig-proxy" for  --no-stdin: strconv.ParseBool: parsing "sig-proxy": invalid syntax
See 'docker attach --help'.
0

[root@dockertest ~]# docker ps -a
CONTAINER ID        IMAGE                     COMMAND             CREATED             STATUS                  PORTS               NAMES
7c110ce78697        docker_testimage:latest   "date"              3 days ago          Exited (0) 3 days ago                       test                

[root@dockertest ~]# /usr/bin/docker -D commit --authormessage 123412341234 test; echo $?
flag provided but not defined: --authormessage
See 'docker commit --help'.
0

Though "load" is now giving an exit code of "1", which is good:

[root@dockertest ~]# docker load --input; echo $?
flag needs an argument: --input
See 'docker load --help'.
[2014-11-24T11:07:10.287030860-05:00] [fatal] log.go:64 flag needs an argument: --input
1

Comment 6 Daniel Walsh 2014-11-24 16:30:17 UTC
Ok you guys are working off of different packages.    We need to test with the updated docker --help patch.  To see if we see the same problems.


shishir could you test with the patch I linked you to, to see if this is still a problem.

Comment 7 Chris Evich 2014-11-24 16:49:43 UTC
Thanks Dan, I'm glad it was just simple package mismatch.  Re-opening so QE can test candidate and/or verify in released/HTB package, including the "--help fix" (unless there's a separate BZ for that aspect).

Comment 9 Chris Evich 2014-12-12 17:16:43 UTC
Verified fixed with docker-1.3.2-4.el7.x86_64

Comment 15 Chris Evich 2015-03-04 15:26:18 UTC
Docker autotest exercizes & verifies command exit codes extensivly.

Comment 16 errata-xmlrpc 2015-03-05 03:19:07 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/RHSA-2015-0623.html


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