@@ -181,70 +181,6 @@ def exec_run(self, cmd, stdout=True, stderr=True, stdin=False, tty=False,
181
181
Raises:
182
182
:py:class:`docker.errors.APIError`
183
183
If the server returns an error.
184
-
185
- Example:
186
-
187
- Create a container that runs in the background
188
-
189
- >>> client = docker.from_env()
190
- >>> container = client.containers.run(
191
- ... 'bfirsh/reticulate-splines', detach=True)
192
-
193
- Prepare the command we are going to use. It prints "hello stdout"
194
- in `stdout`, followed by "hello stderr" in `stderr`:
195
-
196
- >>> cmd = '/bin/sh -c "echo hello stdout ; echo hello stderr >&2"'
197
-
198
- We'll run this command with all four the combinations of ``stream``
199
- and ``demux``.
200
-
201
- With ``stream=False`` and ``demux=False``, the output is a string
202
- that contains both the `stdout` and the `stderr` output:
203
-
204
- >>> res = container.exec_run(cmd, stream=False, demux=False)
205
- >>> res.output
206
- b'hello stderr\n hello stdout\n '
207
-
208
- With ``stream=True``, and ``demux=False``, the output is a
209
- generator that yields strings containing the output of both
210
- `stdout` and `stderr`:
211
-
212
- >>> res = container.exec_run(cmd, stream=True, demux=False)
213
- >>> next(res.output)
214
- b'hello stdout\n '
215
- >>> next(res.output)
216
- b'hello stderr\n '
217
- >>> next(res.output)
218
- Traceback (most recent call last):
219
- File "<stdin>", line 1, in <module>
220
- StopIteration
221
-
222
- With ``stream=True`` and ``demux=True``, the generator now
223
- separates the streams, and yield tuples
224
- ``(stdout, stderr)``:
225
-
226
- >>> res = container.exec_run(cmd, stream=True, demux=True)
227
- >>> next(res.output)
228
- (b'hello stdout\n ', None)
229
- >>> next(res.output)
230
- (None, b'hello stderr\n ')
231
- >>> next(res.output)
232
- Traceback (most recent call last):
233
- File "<stdin>", line 1, in <module>
234
- StopIteration
235
-
236
- Finally, with ``stream=False`` and ``demux=True``, the whole output
237
- is returned, but the streams are still separated:
238
-
239
- >>> res = container.exec_run(cmd, stream=True, demux=True)
240
- >>> next(res.output)
241
- (b'hello stdout\n ', None)
242
- >>> next(res.output)
243
- (None, b'hello stderr\n ')
244
- >>> next(res.output)
245
- Traceback (most recent call last):
246
- File "<stdin>", line 1, in <module>
247
- StopIteration
248
184
"""
249
185
resp = self .client .api .exec_create (
250
186
self .id , cmd , stdout = stdout , stderr = stderr , stdin = stdin , tty = tty ,
0 commit comments