From fdcc4d9a09b02d0632a392e62439ae6ebf4ca7cc Mon Sep 17 00:00:00 2001 From: Aanand Prasad Date: Sun, 1 Sep 2013 01:01:57 -0400 Subject: [PATCH] Set AttachStd* attributes according to detach and stdin_open commands, analogously to the docker cli --- docker/client.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/docker/client.py b/docker/client.py index d20bc069..ed598c27 100644 --- a/docker/client.py +++ b/docker/client.py @@ -106,6 +106,18 @@ class Client(requests.Session): command = shlex.split(str(command)) if isinstance(environment, dict): environment = ['{0}={1}'.format(k, v) for k, v in environment.items()] + + attach_stdin = False + attach_stdout = False + attach_stderr = False + + if not detach: + attach_stdout = True + attach_stderr = True + + if stdin_open: + attach_stdin = True + return { 'Hostname': hostname, 'PortSpecs': ports, @@ -113,9 +125,9 @@ class Client(requests.Session): 'Tty': tty, 'OpenStdin': stdin_open, 'Memory': mem_limit, - 'AttachStdin': False, - 'AttachStdout': False, - 'AttachStderr': False, + 'AttachStdin': attach_stdin, + 'AttachStdout': attach_stdout, + 'AttachStderr': attach_stderr, 'Env': environment, 'Cmd': command, 'Dns': dns,