summaryrefslogtreecommitdiff
path: root/docker/api/exec_api.py
diff options
context:
space:
mode:
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)