Hide Forgot
Description of problem: The docker-latest package is not working correctly with python-doker-py library when executing commands inside of the container. The call is returning immediately, without even waiting for the command to finish. The return code is not even set (itβs None) which should never happen since this is a blocking call. If we wait a second and inspect the call again, the return code is then set to 126. Using docker package works, using docker-latest package in version up to 1.13.1-11 (including) works too. Versions newer than 1.13.1-11 are broken. Version-Release number of selected component (if applicable): docker-latest-1.13.1-23.git28ae36d.el7.x86_64 python-docker-py-1.10.6-1.el7.noarch How reproducible: Always. Steps to Reproduce: $ yum install docker-latest python-docker-py $ systemctl start docker-latest $ docker pull rhel7 Afterwards please run this Python code: """""""""""""""""""""""""""""""""""" import docker import time d = docker.Client(version="1.22") c = d.create_container("rhel7", command='sleep 10') d.start(container=c) exe = d.exec_create(container=c, cmd='ls -la /') out = d.exec_start(exe) ret = d.exec_inspect(exe) print(ret) time.sleep(1) ret = d.exec_inspect(exe) print(ret) print(out) """""""""""""""""""""""""""""""""""" Actual results: """""""""""""""""""""""""""""""""""" {u'OpenStderr': True, u'OpenStdout': True, u'ContainerID': u'ba7dee35c4baa67846475b83a722c8463ff00177c957712666ef37394fe8783a', u'DetachKeys': u'', u'Pid': 0, u'CanRemove': False, u'Running': True, u'ProcessConfig': {u'tty': False, u'entrypoint': u'ls', u'arguments': [u'-la', u'/'], u'privileged': False}, u'ExitCode': None, u'ID': u'4474fb4afa55763e1568306746b30328b5d639bdfe43bf7e253ba9f95797205e', u'OpenStdin': False} {u'OpenStderr': True, u'OpenStdout': True, u'ContainerID': u'ba7dee35c4baa67846475b83a722c8463ff00177c957712666ef37394fe8783a', u'DetachKeys': u'', u'Pid': 14753, u'CanRemove': False, u'Running': False, u'ProcessConfig': {u'tty': False, u'entrypoint': u'ls', u'arguments': [u'-la', u'/'], u'privileged': False}, u'ExitCode': 126, u'ID': u'4474fb4afa55763e1568306746b30328b5d639bdfe43bf7e253ba9f95797205e', u'OpenStdin': False} """""""""""""""""""""""""""""""""""" Please note the ExitCode! Expected results: """""""""""""""""""""""""""""""""""" {u'OpenStderr': True, u'OpenStdout': True, u'ContainerID': u'750ed7c464e5505e7e418f6028e76124571af46054b13343a94bc4fe338490cc', u'DetachKeys': u'', u'Pid': 14140, u'CanRemove': False, u'Running': False, u'ProcessConfig': {u'tty': False, u'entrypoint': u'ls', u'arguments': [u'-la', u'/'], u'privileged': False}, u'ExitCode': 0, u'ID': u'd0aaf6d82419300a6dac4a071d9d534d33e5e494efcbc71967987707c31c2971', u'OpenStdin': False} {u'OpenStderr': True, u'OpenStdout': True, u'ContainerID': u'750ed7c464e5505e7e418f6028e76124571af46054b13343a94bc4fe338490cc', u'DetachKeys': u'', u'Pid': 14140, u'CanRemove': False, u'Running': False, u'ProcessConfig': {u'tty': False, u'entrypoint': u'ls', u'arguments': [u'-la', u'/'], u'privileged': False}, u'ExitCode': 0, u'ID': u'd0aaf6d82419300a6dac4a071d9d534d33e5e494efcbc71967987707c31c2971', u'OpenStdin': False} total 60 dr-xr-xr-x. 18 root root 4096 Oct 13 07:36 . dr-xr-xr-x. 18 root root 4096 Oct 13 07:36 .. -rwxr-xr-x. 1 root root 0 Oct 13 07:36 .dockerenv lrwxrwxrwx. 1 root root 7 Sep 28 17:35 bin -> usr/bin dr-xr-xr-x. 2 root root 4096 Mar 10 2016 boot drwxr-xr-x. 5 root root 360 Oct 13 07:36 dev drwxr-xr-x. 49 root root 4096 Oct 13 07:36 etc drwxr-xr-x. 2 root root 4096 Sep 28 17:39 home lrwxrwxrwx. 1 root root 7 Sep 28 17:35 lib -> usr/lib lrwxrwxrwx. 1 root root 9 Sep 28 17:35 lib64 -> usr/lib64 drwx------. 2 root root 4096 Sep 28 17:34 lost+found drwxr-xr-x. 2 root root 4096 Mar 10 2016 media drwxr-xr-x. 2 root root 4096 Mar 10 2016 mnt drwxr-xr-x. 2 root root 4096 Mar 10 2016 opt dr-xr-xr-x. 167 root root 0 Oct 13 07:36 proc dr-xr-x---. 3 root root 4096 Sep 28 17:43 root drwxr-xr-x. 12 root root 4096 Sep 28 17:43 run lrwxrwxrwx. 1 root root 8 Sep 28 17:35 sbin -> usr/sbin drwxr-xr-x. 2 root root 4096 Mar 10 2016 srv dr-xr-xr-x. 13 root root 0 Oct 10 10:53 sys drwxrwxrwt. 7 root root 4096 Sep 28 17:39 tmp drwxr-xr-x. 13 root root 4096 Sep 28 17:35 usr drwxr-xr-x. 18 root root 4096 Sep 28 17:36 var """""""""""""""""""""""""""""""""""" Additional info: There is a workaround available: $ yum downgrade docker-latest-1.13.1-11.git3a17ad5.el7 docker-client-latest-1.13.1-11.git3a17ad5.el7
We've isolated the failure to these release updates: BAD: 1.13.1-13.gitb303bf6.el7 GOOD: 1.13.1-11.git3a17ad5.el7
Is this a matter of the docker-py package needing to be updated?
The reason I haven't updated python-docker-py is that right now we have the latest upstream release of 1.x series, namely 1.10.6. Since that release, the upstream software changed significantly (API changed, upstream docker-py 2.x and 3.x are backwards incompatible, some options and arguments were removed/redesigned, platform support changed). In Fedora, we renamed the package to python-docker. I advise to do the same thing in case we want to update to 2.x (or even 3.x).
Reproducer (improved version from the original post): #!/usr/bin/python import docker import time d = docker.Client(version="1.22") for i in range(100): print("iteration %d" % i) c = d.create_container("rhel7", command='sleep 10') d.start(container=c) exe = d.exec_create(container=c, cmd='ls -la /') out = d.exec_start(exe) time.sleep(0.5) ret = d.exec_inspect(exe) if ret["ExitCode"] > 0: raise Exception("command failed when it shouldn't have") if not out: raise Exception("no output, there should be something")
Tried with: docker-latest-1.13.1-61.git87f2fab.el7.x86_64 python-docker-py-1.10.6-4.el7.noarch The EXIT code shows 0 all the time. There is similar bugs here: https://bugzilla.redhat.com/show_bug.cgi?id=1579814
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://access.redhat.com/errata/RHBA-2018:2025