Skip to content

Commit ad208df

Browse files
committed
Container.exec_run returns None as exit_code if stream or socket
Signed-off-by: Frank Sachsenheim <[email protected]>
1 parent 9c0332e commit ad208df

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

docker/models/containers.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ def exec_run(self, cmd, stdout=True, stderr=True, stdin=False, tty=False,
152152
Returns:
153153
(tuple): A tuple of (exit_code, output)
154154
exit_code: (int):
155-
Exit code for the executed command
155+
Exit code for the executed command or ``None`` if
156+
either ``stream```or ``socket`` is ``True``.
156157
output: (generator or str):
157158
If ``stream=True``, a generator yielding response chunks.
158159
If ``socket=True``, a socket object for the connection.
@@ -170,10 +171,11 @@ def exec_run(self, cmd, stdout=True, stderr=True, stdin=False, tty=False,
170171
exec_output = self.client.api.exec_start(
171172
resp['Id'], detach=detach, tty=tty, stream=stream, socket=socket
172173
)
173-
exit_code = 0
174-
if stream is False:
175-
exit_code = self.client.api.exec_inspect(resp['Id'])['ExitCode']
176-
return (exit_code, exec_output)
174+
if socket or stream:
175+
return None, exec_output
176+
else:
177+
return (self.client.api.exec_inspect(resp['Id'])['ExitCode'],
178+
exec_output)
177179

178180
def export(self):
179181
"""

0 commit comments

Comments
 (0)