Updated exec API documentation

This commit is contained in:
Joffrey F 2015-04-27 14:11:43 -07:00
parent e2ad91bdf7
commit e337a2317e
3 changed files with 44 additions and 17 deletions

View File

@ -526,8 +526,7 @@ class Client(requests.Session):
return self.exec_start(create_res, detach, tty, stream) return self.exec_start(create_res, detach, tty, stream)
def exec_create(self, container, cmd, detach=False, stdout=True, def exec_create(self, container, cmd, stdout=True, stderr=True, tty=False):
stderr=True, tty=False):
if utils.compare_version('1.15', self._version) < 0: if utils.compare_version('1.15', self._version) < 0:
raise errors.InvalidVersion('Exec is not supported in API < 1.15') raise errors.InvalidVersion('Exec is not supported in API < 1.15')
if isinstance(container, dict): if isinstance(container, dict):
@ -543,7 +542,6 @@ class Client(requests.Session):
'AttachStdin': False, 'AttachStdin': False,
'AttachStdout': stdout, 'AttachStdout': stdout,
'AttachStderr': stderr, 'AttachStderr': stderr,
'Detach': detach,
'Cmd': cmd 'Cmd': cmd
} }

View File

@ -256,28 +256,58 @@ function return a blocking generator you can iterate over to retrieve events as
## execute ## execute
```python This command is deprecated for docker-py >= 1.2.0 ; use `exec_create` and
c.execute(container, cmd, detach=False, stdout=True, stderr=True, `exec_start` instead.
stream=False, tty=False)
```
Execute a command in a running container. ## exec_create
Sets up an exec instance in a running container.
**Params**: **Params**:
* container (str): can be a container dictionary (result of * container (str): Target container where exec instance will be created
running `inspect_container`), unique id or container name. * cmd (str or list): Command to be executed
* stdout (bool): Attach to stdout of the exec command if true. Default: True
* stderr (bool): Attach to stderr of the exec command if true. Default: True
* tty (bool): Allocate a pseudo-TTY. Default: False
**Returns** (dict): A dictionary with an exec 'Id' key.
* cmd (str or list): representing the command and its arguments. ## exec_inspect
* detach (bool): flag to `True` will run the process in the background. Return low-level information about an exec command.
* stdout (bool): indicates which output streams to read from. **Params**:
* stderr (bool): indicates which output streams to read from.
* stream (bool): indicates whether to return a generator which will yield * exec_id (str): ID of the exec instance
the streaming response in chunks.
**Returns** (dict): Dictionary of values returned by the endpoint.
## exec_resize
Resize the tty session used by the specified exec command.
**Params**:
* exec_id (str): ID of the exec instance
* height (int): Height of tty session
* width (int): Width of tty session
## exec_start
Start a previously set up exec instance.
**Params**:
* exec_id (str): ID of the exec instance
* detach (bool): If true, detach from the exec command. Default: False
* tty (bool): Allocate a pseudo-TTY. Default: False
* stream (bool): Stream response data
**Returns** (generator or str): If `stream=True`, a generator yielding response
chunks. A string containing response data otherwise.
## export ## export

View File

@ -1601,7 +1601,6 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
'Tty': False, 'Tty': False,
'AttachStdout': True, 'AttachStdout': True,
'Container': fake_api.FAKE_CONTAINER_ID, 'Container': fake_api.FAKE_CONTAINER_ID,
'Detach': False,
'Cmd': ['ls', '-1'], 'Cmd': ['ls', '-1'],
'Privileged': False, 'Privileged': False,
'AttachStdin': False, 'AttachStdin': False,