mirror of https://github.com/docker/docker-py.git
Set AttachStd* attributes according to detach and stdin_open commands, analogously to the docker cli
This commit is contained in:
parent
6dff1efde7
commit
fdcc4d9a09
|
@ -106,6 +106,18 @@ class Client(requests.Session):
|
||||||
command = shlex.split(str(command))
|
command = shlex.split(str(command))
|
||||||
if isinstance(environment, dict):
|
if isinstance(environment, dict):
|
||||||
environment = ['{0}={1}'.format(k, v) for k, v in environment.items()]
|
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 {
|
return {
|
||||||
'Hostname': hostname,
|
'Hostname': hostname,
|
||||||
'PortSpecs': ports,
|
'PortSpecs': ports,
|
||||||
|
@ -113,9 +125,9 @@ class Client(requests.Session):
|
||||||
'Tty': tty,
|
'Tty': tty,
|
||||||
'OpenStdin': stdin_open,
|
'OpenStdin': stdin_open,
|
||||||
'Memory': mem_limit,
|
'Memory': mem_limit,
|
||||||
'AttachStdin': False,
|
'AttachStdin': attach_stdin,
|
||||||
'AttachStdout': False,
|
'AttachStdout': attach_stdout,
|
||||||
'AttachStderr': False,
|
'AttachStderr': attach_stderr,
|
||||||
'Env': environment,
|
'Env': environment,
|
||||||
'Cmd': command,
|
'Cmd': command,
|
||||||
'Dns': dns,
|
'Dns': dns,
|
||||||
|
|
Loading…
Reference in New Issue