summaryrefslogtreecommitdiff
path: root/docker/api/exec_api.py
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2018-01-25 14:17:26 -0800
committerJoffrey F <joffrey@docker.com>2018-01-25 17:32:07 -0800
commit33db9d78ce8903b03175e8ad8c5a0ba9865bf2e4 (patch)
tree749e2db6d5f247845094c9240887616e7714b16b /docker/api/exec_api.py
parent9e2148dcc417c1fd613a69ee558c64349b30173d (diff)
downloaddocker-py-bump_api_version_1.35.tar.gz
Bump default API version to 1.35bump_api_version_1.35
Add ContainerSpec.isolation support Add until support in logs Add condition support in wait Add workdir support in exec_create Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'docker/api/exec_api.py')
-rw-r--r--docker/api/exec_api.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/docker/api/exec_api.py b/docker/api/exec_api.py
index cff5cfa..029c984 100644
--- a/docker/api/exec_api.py
+++ b/docker/api/exec_api.py
@@ -9,7 +9,7 @@ class ExecApiMixin(object):
@utils.check_resource('container')
def exec_create(self, container, cmd, stdout=True, stderr=True,
stdin=False, tty=False, privileged=False, user='',
- environment=None):
+ environment=None, workdir=None):
"""
Sets up an exec instance in a running container.
@@ -26,6 +26,7 @@ class ExecApiMixin(object):
environment (dict or list): A dictionary or a list of strings in
the following format ``["PASSWORD=xxx"]`` or
``{"PASSWORD": "xxx"}``.
+ workdir (str): Path to working directory for this exec session
Returns:
(dict): A dictionary with an exec ``Id`` key.
@@ -66,6 +67,13 @@ class ExecApiMixin(object):
'Env': environment,
}
+ if workdir is not None:
+ if utils.version_lt(self._version, '1.35'):
+ raise errors.InvalidVersion(
+ 'workdir is not supported for API version < 1.35'
+ )
+ data['WorkingDir'] = workdir
+
url = self._url('/containers/{0}/exec', container)
res = self._post_json(url, data=data)
return self._result(res, True)