Skip to content

Commit e337a23

Browse files
committed
Updated exec API documentation
1 parent e2ad91b commit e337a23

File tree

3 files changed

+44
-17
lines changed

3 files changed

+44
-17
lines changed

docker/client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,7 @@ def execute(self, container, cmd, detach=False, stdout=True, stderr=True,
526526

527527
return self.exec_start(create_res, detach, tty, stream)
528528

529-
def exec_create(self, container, cmd, detach=False, stdout=True,
530-
stderr=True, tty=False):
529+
def exec_create(self, container, cmd, stdout=True, stderr=True, tty=False):
531530
if utils.compare_version('1.15', self._version) < 0:
532531
raise errors.InvalidVersion('Exec is not supported in API < 1.15')
533532
if isinstance(container, dict):
@@ -543,7 +542,6 @@ def exec_create(self, container, cmd, detach=False, stdout=True,
543542
'AttachStdin': False,
544543
'AttachStdout': stdout,
545544
'AttachStderr': stderr,
546-
'Detach': detach,
547545
'Cmd': cmd
548546
}
549547

docs/api.md

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -256,28 +256,58 @@ function return a blocking generator you can iterate over to retrieve events as
256256

257257
## execute
258258

259-
```python
260-
c.execute(container, cmd, detach=False, stdout=True, stderr=True,
261-
stream=False, tty=False)
262-
```
259+
This command is deprecated for docker-py >= 1.2.0 ; use `exec_create` and
260+
`exec_start` instead.
261+
262+
## exec_create
263+
264+
Sets up an exec instance in a running container.
265+
266+
**Params**:
267+
268+
* container (str): Target container where exec instance will be created
269+
* cmd (str or list): Command to be executed
270+
* stdout (bool): Attach to stdout of the exec command if true. Default: True
271+
* stderr (bool): Attach to stderr of the exec command if true. Default: True
272+
* tty (bool): Allocate a pseudo-TTY. Default: False
273+
274+
**Returns** (dict): A dictionary with an exec 'Id' key.
275+
263276

264-
Execute a command in a running container.
277+
## exec_inspect
278+
279+
Return low-level information about an exec command.
265280

266281
**Params**:
267282

268-
* container (str): can be a container dictionary (result of
269-
running `inspect_container`), unique id or container name.
283+
* exec_id (str): ID of the exec instance
284+
285+
**Returns** (dict): Dictionary of values returned by the endpoint.
286+
270287

288+
## exec_resize
271289

272-
* cmd (str or list): representing the command and its arguments.
290+
Resize the tty session used by the specified exec command.
291+
292+
**Params**:
273293

274-
* detach (bool): flag to `True` will run the process in the background.
294+
* exec_id (str): ID of the exec instance
295+
* height (int): Height of tty session
296+
* width (int): Width of tty session
297+
298+
## exec_start
299+
300+
Start a previously set up exec instance.
301+
302+
**Params**:
275303

276-
* stdout (bool): indicates which output streams to read from.
277-
* stderr (bool): indicates which output streams to read from.
304+
* exec_id (str): ID of the exec instance
305+
* detach (bool): If true, detach from the exec command. Default: False
306+
* tty (bool): Allocate a pseudo-TTY. Default: False
307+
* stream (bool): Stream response data
278308

279-
* stream (bool): indicates whether to return a generator which will yield
280-
the streaming response in chunks.
309+
**Returns** (generator or str): If `stream=True`, a generator yielding response
310+
chunks. A string containing response data otherwise.
281311

282312
## export
283313

tests/test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1601,7 +1601,6 @@ def test_exec_create(self):
16011601
'Tty': False,
16021602
'AttachStdout': True,
16031603
'Container': fake_api.FAKE_CONTAINER_ID,
1604-
'Detach': False,
16051604
'Cmd': ['ls', '-1'],
16061605
'Privileged': False,
16071606
'AttachStdin': False,

0 commit comments

Comments
 (0)